Unable to Telnet into port 25 on CentOS PostFix Server

I'm trying to telnet into port 25 on a CentOS server that runs PostFix to test sending email messages from the server.

When I try to telnet in from another CentOS box on the same network I get the message below:

 Unable to connect to remote host: Connection refused 

SELinux is disabled and I've opened port 25 in iptables...what else should I be looking at?


Run the following the check if postfix is listening on port 25/tcp:

netstat -plnt |grep :25

You should see a line like:

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 2460/master

If you don't see such a line, check /etc/postfix/master.cf.

In that file, you should see a line like:

smtp      inet  n       -       n       -       -       smtpd

The first column is the port, which postfix derives from /etc/services.

You should look up general documentation on setting up Postfix, so your server doesn't become a spam relay. The CentOS wiki has fairly good documentation in that regard.

Update:

Also, look at http://www.postfix.org/postconf.5.html#inet_interfaces which will describe how to configure Postfix to listen on different network interfaces. The relevant line will be found in /etc/postfix/main.cf.


I edited the file /etc/postfix/main.cf. The parameter to look up was

inet_interfaces = localhost

I changed it to

inet_interfaces = $myhostname, localhost

Restart postfix. The problem was fixed.


I had this problem and found that I needed to do:

# service postfix stop

followed (a bit later) by

# service postfix start

Postfix reload did not seem to close and then re-open the required ports.


I generally only see the Connection Refused message if there is nothing listening. Are you sure you have an SMTP server running on the external IP address? Check with

netstat -tunlp | grep 25
tcp      0    0 127.0.0.1:25              0.0.0.0:*         LISTEN    1743/master

Here you can see I'm only running on the loopback interface.


Check your /etc/hosts.allow and /etc/hosts.deny files. Maybe the telnet or the ports are blocked in those?!