Application developers make use of PostFix --- a Mail Transfer Agent --- to send emails from their applications. Often, the users of Postfix face the 'Connection timed out' error while trying to send emails from their local servers using their applications. There are many reasons for the connection to be timed out. The steps mentioned below will help you to fix the postfix connection timed out error.
Find the cause for the connection time out:
- Step 1: When you face the Connection timed out error in postfix, check whether you can ping the domain using the telnet command. Check the connectivity either using the domain name or the IP address of the destination server. The format for this is telnet server_domain_name port_number or telnet server_ip_address port_number.
- Step 2: If you can connect using the telnet command, then try to increase the connection time out duration.
- Step 3: If the telnet command failed to establish the connection, then it might be due to the port getting blocked by the ISP or the firewall on your local server.
- Step 4: Mostly, the SMTP port 25 used by the local server might be blocked by several Cloud servers.
- Step 5: In some cases, the local server might be spammed, and as a result, the connection might be refused.
- Step 1: Another option to find the cause for the postfix connection timed out error is to make use of the traceroute command. By using this command, you can know the server where the connection is being lost.
- Step 2: The traceroute command looks like this: traceroute -n -T port_number server_domain_name. Try traceroute with different port numbers to find out the exact cause.
Solutions for postfix connection time out:
This solution can be carried out when the timed out error persists, but the telnet command can establish the connection.
- Step 1: Increase the smtp_connection_timeout parameter in the main.cf file to a value that does not exceed 90 seconds.
- Step 2: Then, re-queue and restart postfix using the commands given below.
- Step 3: postsuper -r ALL /etc/init.d/postfix restart
- Step 4: Now, check whether the connection is established without the postfix connection timed out error.
Change the port number in the master.cf configuration file using the following steps:
- Step 1: Type the command /etc/postfix/master.cf to open the master.cf file.
- Step 2: Locate the line smtp inet n -n - - smtpd.
- Step 3: Change the line as NEW_PORT inet n -n - - smtpd. Here NEW_PORT is must be a port number which is not used by any other service. You can use ports higher than 2048.
Change the nameserver in the resolv.conf file. The steps are as follows:
- Step 1: Type vi /etc/resolv.conf in the terminal window.
- Step 2: Locate the nameserver parameter and change it as nameserver 22.214.171.124.
- Step 3: Then, restart postfix using the sudo /etc/init.d/postfix restart command.
If your server has more than one NIC’s, then use the steps mentioned below.
- Step 1: Open the main.cf file in the terminal.
- Step 2: Locate the parameter inet_interface.
- Step 3: Modify it as inet_interface = all.
- Step 4: Save and exit the configuration file.
- Step 5: Restart postfix.
- Step 1: Check your network firewall, whether it is blocking any port or domain that postfix uses to send emails.
- Step 2: If your server IP has been spammed, then contact your ISP.
- Step 3: As said earlier, the port 25 is blocked by many Cloud servers. So enquire them about the alternate ports to be used. These are the solution to fix postfix connection timed out error.