How to fix Amazon AWS EC2 Connection timed out error in SMTP
Here at Bobcares, we provide Server Administration and Maintenance services to AWS account owners.
An error we sometimes see in Amazon EC2 instances is : Connection timed out error in SMTP
This is usually caused due to various reasons such as mail server security restrictions, network routing issues or even port blocks at ISP or AWS levels.
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 like establishing connection to the mail server and delivering the mails.
This includes authenticating an email account, verifying the email server settings, invoking the mail transfer and delivery agents, connecting 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, when a user is trying to send mails via Outlook, he’ll see the error:
AEA7C9A7D49 19539 Fri Feb 18 11:12:20 email@example.com
(connect to xxxx-com.mail.protection.outlook.com[***.**.***.31]: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 “Connection timed out” error in SMTP
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 SMTP server
- Email server unable to connect to remote mail server
Three variations of this error are:
status=deferred (connect to domain.com[***.*.***.12]:25: Connection timed out)
postfix/smtp: 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 issue 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 sender’s PC to mail server, check the firewall rules in server and confirm that there are no connectivity issues or throttling set within the EC2 instance.
Things can get messed up 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 include 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.
If you are debugging an email connectivity error, make sure the mail server is working fine and SMTP ports are allowed. If the error is obtained while connecting to remote mail server, confirm that network connectivity is fine.
In case the issue persists, look up the mail server IP address and AWS EC2 throttling limits.
Email errors can also be caused by 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.
“Connection timed out” error in SMTP is a class of errors in AWS EC2 instances. It is shown when mail server is unable to connect with the network or due to Amazon’s port limits. Today we’ve seen the common causes for this error, and how to fix them.