Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to open the port 8040 on my centos, but I keep getting connection refused.

This is what I have done:

iptables -I INPUT -m state --state NEW -p tcp --dport 8040 -j ACCEPT
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
/etc/init.d/iptables save
sudo service iptables restart

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:8040
acctboth   all  --  anywhere             anywhere

telnet localhost  8040
telnet: connect to address Connection refused

What else do I need to do?


I tried disabling iptables and selinux, I still get connection refused.

share|improve this question
iptables --flush If you do that all rules will be deleted. If it still fails you have a firewall or something else,not on this computer, is blocking you. – cybernard Apr 7 '13 at 14:35
Have you checked the state of the port with netstat, to make sure it's listening? – parkydr Apr 7 '13 at 15:34
up vote 1 down vote accepted

The connection refused message indicates that there is no service on that port, not that a firewall is blocking it. You must have a listening TCP socket on that port (daemon, server, netcat). Besides, your POLICY is ACCEPT, so anything would get through anyway.

share|improve this answer
ref – Ярослав Рахматуллин Apr 7 '13 at 18:03

Your Answer


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.