Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
Does your provider allow telnetting to that port? –  Lucas Kauffman Mar 20 '12 at 20:13
1  
I'm just trying to test sending mail via smtp from another server. –  Windows Ninja Mar 20 '12 at 20:14
    
Make sure Postfix is started and listening on port 25. service postfix status and netstat -anp | grep LISTEN –  Aaron Copley Mar 20 '12 at 20:16
1  
Your ISP may block outgoing port 25, because that's something spambots will use. Can you telnet gmail-smtp-in.l.google.com 25? That's a GMail MTA, and you can be sure something is listening to port 25 on that server. If you get blocked, then your ISP is blocking you. –  cjc Mar 20 '12 at 20:17
2  
@mdpc, LucidLuniz is testing network functionality. He's not trying to connect and log in. telnet is a good tool for checking if something is listening to a TCP port and possibly issue commands to that service. –  cjc Mar 20 '12 at 20:18

5 Answers 5

up vote 6 down vote accepted

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.

share|improve this answer
    
When running that command I see this: tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 30948/master so it seems as though port 25 should allow connections, correct? –  Windows Ninja Mar 21 '12 at 10:54
    
No, it's only listening on localhost (the 127.0.0.1) address. For it to be available on the Internet, you'll have to configure it to listen on, at least, the public network interface or on all interfaces. Look at /etc/postfix/main.cf and find the inet_interfaces line. It's probably set to 127.0.0.1 or "loopback-only". Change that to "all". Take a look at the Postfix docs here: postfix.org/postconf.5.html#inet_interfaces –  cjc Mar 21 '12 at 11:15
    
I don't need this to be publicly accessible. It only needs to be accessible from a server within our network (that I'm trying to telnet into it from). Sorry, I should have explained that upfront. –  Windows Ninja Mar 21 '12 at 11:24
    
Sure, just use the private IP for the inet_interfaces line, then. –  cjc Mar 21 '12 at 11:28
    
Yep, that worked (I just added the local server name and restarted postfix). Thanks for your help cjc and everybody else! –  Windows Ninja Mar 21 '12 at 11:31

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

inet_interfaces = localhost

I changed it to

inet_interfaces = $myhostname, localhost

Restart postfix. The problem was fixed.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
    
If I remember correctly, CentOS comes with IPTables enabled by default. Perhaps that is blocking your port? –  djangofan Nov 13 '12 at 17:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.