Bobcares

How to fix Amazon EC2 SMTP Connection timed out error

by | Mar 10, 2018

Quite frequently, AWS users experience EC2 SMTP Connection timed out error when sending emails.

This is usually caused due to mail server security restrictions, network routing issues or even port blocks at ISP or AWS levels.

Here at Bobcares, we provide Server Administration and Maintenance services to AWS account owners.

We’ll take a look at how we resolve SMTP errors in EC2 instances.

 

What is AWS EC2 “Connection timed out” error in SMTP?

When you or your customers try to send mails using your mail server in the AWS EC2 instance, it performs a series of steps. It will establish the connection to the mail server and then deliver the mails.

This includes authenticating an email account, verifying the email server settings, etc. It also invokes the mail transfer and delivery agents, connects to the remote mail server, and so on.

If any of those steps fail for a hundred different reasons, the mail delivery process fails.

Today, we’ll look at the top few reasons for this failure, and the fixes for it:

 

Resolving AWS EC2 “Connection timed out” error in SMTP

This happens because the email account user is unable to connect to the mail server.

For example, in a customer’s AWS server, when a user tried to send mails to a Gmail address, he got the error:

Jan 10 12:52:45 postfix-xxxxx postfix/smtp[4001]: xxxx: to=, relay=none, delay=2323, delays=2233/0.01/90/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[64.233.177.27]:25: Connection timed out)”

To resolve this error, first, we need to determine the cause of the error.

Local connectivity issues, AWS throttling for port 25 on EC2 instances, server firewalls or mail server misconfiguration, anything can lead to such errors.

If you are facing this error, and need help, click here to request expert assistance.

 

How to fix AWS EC2 SMTPConnection timed out error

This error occurs mainly due to 3 main reasons:

  • Email client unable to connect to the mail server
  • AWS limiting the connections to port 25 of the SMTP server
  • Email server unable to connect to a remote mail server

Three variations of this error are:

  • status=deferred (connect to domain.com[***.*.***.12]:25: Connection timed out)

  • postfix/smtp[1261]: connect to domain.com[***.*.***.12]:25: Connection timed out

  • qmail: 1291975084.251298 delivery 1234: deferral: Sorry,_I_wasn’t_able_to_establish_an_SMTP_connection._(#4.4.1)

All these happen because of some connectivity issues between the email sender and the recipient mail server. Possibly due to a server misconfiguration, port blocks or connectivity issues.

To fix this, you’ll need to verify the connectivity from the sender’s PC to the mail server. Then, check the firewall rules in the server and confirm that there are no connectivity issues or throttling set within the EC2 instance.

Things can go wrong when editing firewall rules or mail server configuration files. So the edits have to be done carefully.

However, if you need help, our server experts can fix this for you in an hour. Click here to go to our server administration services page.

 

Fixing the “Connection timed out” error in SMTP

For users to send mails via AWS EC2 instances, the mail server connectivity and the SMTP ports should be working fine. This includes allowing SMTP port in the firewalls, ensuring proper network connectivity in EC2, resolving DNS issues, etc.

Even a slight misconfiguration in the mail server or email client settings can cause email delivery to fail.

 

Verifying connection

As the first step in debugging an email connectivity error, we make sure the mail server is working fine and allows SMTP ports.

If there are errors while connecting to the remote mail server, we first confirm that network connectivity. Also, we make sure that the security group outbound (egress) rules allow traffic to the SMTP server on TCP port 25, 587, or 465.

Further, we use the telnet command to check the connection from the command-line. Based on the port in use, we use one of the commands,

telnet email-server.com 587
telnet email-server.com 25
telnet email-server.com 465

 

Remove AWS EC2 throttling limits

In case the issue persists,  we look up the mail server IP address and AWS EC2 throttling limits.

Amazon EC2 restricts traffic on port 25 of all EC2 instances by default. Therefore, we request AWS to remove the port 25 restrictions on the instance.

For this, we log in to the AWS account and open a Request to Remove Email Sending Limitations form. Here, we provide the details of our use case.
Also as per customer requirements, we often provide the AWS-owned Elastic IP addresses that the server uses to send outbound emails. This helps to reduce the occurrences of emails sent from the Elastic IP addresses being marked as spam.

Email errors can also occur due to mail server configuration issues or email routing problems.

If you need help, our server experts are on standby 24/7. Click here to open a server administration request.

 

Conclusion

In short, EC2 SMTP Connection timed out error shows up due to network connection errors or Amazon’s port limits. Today we’ve seen the common causes for this error, and how to fix them.

PREVENT EMAIL ERRORS IN YOUR EC2!

Our server experts will resolve your email errors, prevent spamming, configure firewall rules, and tweak your services, so that you never have to worry about email errors again.

Contact us for expert assistance!

RESOLVE YOUR EMAIL ERRORS.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF