Search My Techie Guy

Friday, April 22, 2016

Sendmail SMTP Port 25 - Unable to connect to remote host: Connection refused

Summary: 

When you telnet a local address on port 25 (SMTP) you get error below:

"Unable to connect to remote host: Connection refused"

Problem or Goal:

When you attempt to connect to port 25 on a local address, you get error:
 "Unable to connect to remote host: Connection refused"

root@mail:/etc/mail# telnet 10.0.40.104 25
Trying 10.0.40.104...
telnet: Unable to connect to remote host: Connection refused

Yet you can successfully connect to port 25 on localhost or 127.0.0.1

root@mail:/etc/mail# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.


Cause: 

By default, sendmail will only listen on localhost.

Solution: 

Set it to listen on all interfaces instead:

1. Open /etc/mail/sendmail.cf
2. Find the line starting with DaemonPortOptions and then modify it so it looks like this:

Before:
# SMTP daemon options
O DaemonPortOptions=Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1

After:
# SMTP daemon options
O DaemonPortOptions=Family=inet,  Name=MTA-v4, Port=smtp, Addr=0.0.0.0

3. Make sure to restart sendmail so that our new configuration is taken in to effect:

/etc/init.d/sendmail restart

Problem Solved?

YES

root@mail:/etc/mail# telnet 10.0.40.104 25
Trying 10.0.40.104...
Connected to 10.0.40.104.
Escape character is '^]'.

Post a Comment