[CentOS] iptables for PostgreSQL not working

Wed Sep 1 01:09:19 UTC 2010
Carlos S <neubyr at gmail.com>


I am having problem in configuring iptables for PostgreSQL server. I
added following rule to iptables to allow connections to default
PostgreSQL port (5432):
sudo /sbin/iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp
-p tcp -s --dport 5432 -j ACCEPT

After this I can't connect using telnet or psql (postgres client).
Following error is received from telnet on MacOS and CentOS:
MacOS$  telnet 5432
telnet: connect to address Connection refused
telnet: Unable to connect to remote host

CentOS$ telnet 5432
telnet: connect to address No route to host

I tried removing source address constraint and to allow connections
from all hosts, however that didn't make any difference.

* The connection works fine when I stop iptables firewall.

I am sure there is no rule before this 5432 rule which is refusing
connections. The PostgreSQL server is running and accepting localhost
connections. Also, hosts.allow and hosts.deny file are not refusing
connections. Any help on what might be wrong?