Server Fault is a question and answer site for system and network administrators. 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 have a VPS for Apples push notification service I am trying to open a port 2195. I am currently doing this

vi /etc/sysconfig/iptables

then I go to insert mode of vi and enter these two lines

-A -I INPUT -p tcp --dport 2195 -j ACCEPT
-A -I OUTPUT -p tcp --dport 2195 -j ACCEPT

then I save the file and quit vi.

Then I restart iptables service by

service iptables restart.

But after that when I try to telnet by doing

 telnet localhost 2195

I get this

Trying telnet: connect to address Connection refused

Any pointers....?

Server is red hat on hostgator

share|improve this question
Could you add the output of iptables -L -n -v ? The policy of each chain and any other rules will be important in answering this question. – Ladadadada Jan 25 '12 at 7:46
Try telnet your_ip 2195 and see if in this way is working. Where your_ip is the real ip not . – Sacx Jan 25 '12 at 7:47

Your rules are bad. You can't use -A and -I together, -A means append as last rule, -I menas insert as first rule.

share|improve this answer
Good spot. I didn't even notice that. I just jumped straight to the port bit. – Ladadadada Jan 25 '12 at 8:26

Two things I notice immediately:

  1. You have allowed packets out with a destination port of 2195 but if someone contacts your server on 2195 then your return packets will have a source port of 2195. Depending on what traffic is needed, you can either change the --dport in the OUTPUT chain to --sport or add two extra rules with --sport as well.
  2. A connection refused error implies different things about what has happened to the connection than a timeout would. It suggests that your service is not listening on port 2195. Could you run netstat -tan | grep LISTEN and check that your service is listening on port 2195 on the loopback interface?
share|improve this answer

Please first validate your rules are applied or not via

sudo iptables -L -vnx

If the rules is there, make sure the service which listens on 2195 is running or not.

sudo netstat -tulpn 
share|improve this answer

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.