Categories
Unix

Postfix shows Connection Timed Out but direct telnet works

I ran into an interesting problem the other day when a client’s mail server was failing to send email. If you viewed the mail queue you would see a lot of “Connection timed out” errors.

Now one way to test this is to manually telnet to port 25 of the server you are emailing to, and walk through the handshaking manually. This in fact worked in this case! So why wouldn’t Postfix work?

The one thing that comes to mind is the ISP is not allowing port 25 outgoing, or in general it is a firewall issue. But as I said, I could use telnet just fine.

I found that the server had multiple IP addresses configured, and indeed it was a firewall issue, BUT only on some of the IPs! You can configure Postfix to use certain IPs outbound under certain scenarios, which was exactly the problem. After editing “/etc/postfix/master.cf” and reviewing the lines with “smtp_bind_address”, once I updated those address settings to be the main server IP that was allowed outbound, then everything worked.