I'm using centOS.

I want to implement a smtp mail server, and I have installed postfix and dovecot(both have been set correctly).

I tried to telnet the 25 port, but it returns Unable to connect to remote host: Connection refused

So, How can I open the 25 port? Thanks!


make sure postfix is listening on the external IP for port 25. By default it only looks on

If you have this

inet_interfaces = localhost

Put a # in front of that line and remove the comment from

#inet_interfaces = all

Then restart postfix

service postfix restart
  • I have done this setting already. – liuxingruo May 10 '10 at 13:25
  • This answer is pretty old, but solved my problem. Thank you @mike – Aakash Mar 14 '18 at 11:32

Assuming you actually have a service listening on that port you would do something like the following to open up the firewall if the ip of your server is

sudo iptables -I RH-Firewall-1-INPUT 5 -p tcp -d -m tcp --dport 25 -j ACCEPT

You want to list the rules with:

sudo iptables -L -n --line-numbers

To make sure you put it in the right place. Here is a tutorial that covers the basics of iptables with CentOS.

  • Note that sudo is not set up for any users in the default configuration on CentOS – Ophidian May 10 '10 at 13:23
  • It returns iptables: No chain/target/match by that name – liuxingruo May 10 '10 at 13:24
  • It would also be handy if you could run: netstat -nltp that will show what proceses are listening on what ports on TCP. – Jason Tan May 10 '10 at 13:43
  • EN 1869/cupsd tcp 0 0* LIST – liuxingruo May 10 '10 at 13:52
  • Oh ya, after the change if all is good you want service iptables save – Kyle Brandt May 10 '10 at 13:55

The easiest way to accomplish this on CentOS is probably to use this utility:

sudo /usr/bin/system-config-securitylevel-tui

Here's another solution



Add the following line in

-A INPUT -p tcp -m tcp --dport 25 --syn -j ACCEPT

Restart iptables

service iptables restart
  • Unloading iptables modules: Applying iptables firewall rules: iptables-restore: line 7 failed – liuxingruo May 10 '10 at 13:51
  • I edited the line to put in your iptables script – Mike May 10 '10 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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