Software⏱️ 3 min read📅 2026-06-19

How to Fix: Postfix - SMTP mail delivery failed with "Connection timed out" error

Postfix SMTP mail delivery failed with Connection timed out error analysis and solution.

Quick Answer: Try increasing the inet_protocols value in /etc/postfix/main.cf to 'ipv4, ipv6' and restart postfix server.

Postfix SMTP mail delivery failed with 'Connection timed out' error

This issue affects users who have installed postfix mail server in Ubuntu machine and are facing difficulties sending emails to other domain mail servers like Google, Yahoo, Outlook. It can be frustrating when email sending fails intermittently, but there's a solution to resolve this issue.

🔍 Why This Happens

  • The primary reason for this error is that the postfix server is unable to establish a stable connection with the target SMTP server due to network connectivity issues or firewall rules blocking the port 25 traffic. This can be further exacerbated by the use of self-signed certificates, which may not be trusted by all mail servers.
  • An alternative reason could be the DNS resolution issue for the target SMTP server's hostname. Even if Telnet to the port 25 works randomly, it doesn't guarantee that the DNS lookup is successful, leading to connection timeouts.

🔧 Proven Troubleshooting Steps

Change the 'inet_protocols' value in main.cf and ensure postfix uses IPv4 only

  1. Step 1: Open the file '/etc/postfix/main.cf' using a text editor and locate the line starting with 'inet_protocols'. Change its value to 'ipv4' by adding or replacing the existing value. For example, add the following line: inet_protocols = ipv4
  2. Step 2: Save the changes to the main.cf file and restart the postfix server service to apply the changes. This step ensures that postfix only uses IPv4 for network communication, which can help resolve connectivity issues.
  3. Step 3: Verify that the 'inet_protocols' value has been updated correctly by running the following command: grep inet_protocols /etc/postfix/main.cf

Configure DNS resolution and firewall rules to allow port 25 traffic

  1. Step 1: Check the target SMTP server's hostname and ensure it is correctly configured in the postfix configuration file. For example, update the 'mydestination' variable to include the correct hostname: mydestination = $myhostname, $mydomain, $proxyhost, $smtpd_proxy_domain
  2. Step 2: Verify that the DNS lookup for the target SMTP server's hostname is successful by running the following command: dig +short mx4.hotmail.com

✨ Wrapping Up

To resolve the 'Connection timed out' error in postfix SMTP mail delivery, try changing the 'inet_protocols' value to 'ipv4' and restarting the postfix server. If this doesn't work, check the DNS resolution for the target SMTP server's hostname and configure firewall rules to allow port 25 traffic. By following these steps, you should be able to resolve the issue and send emails successfully.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions