Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

What else do I need to do?

Update:

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
1  
Have you checked the state of the port with netstat, to make sure it's listening? –  parkydr Apr 7 '13 at 15:34
add comment

1 Answer

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
add comment

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.