I have an operating environment in CentOS 6.3 that has tomcat7 and postgres9.2 installed. There is just one web application deployed in tomcat that tries to establish a connection from localhost to postgres. The following is the contents of /etc/sysconfig/iptables

#Filter table
:INPUT DROP [9:2530]
:OUTPUT ACCEPT [88:11968]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8443 -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT


-A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8443

Tomcat only allows https and listens for requests at port 8443. Currently I forward requests from port 443 to 8443 so that users don't have to specify port numbers in the URL. Web pages are happily accessible from a browser, but web application fails to work. From tomcat logs, hibernate fails to establish a connection with postgres even though netstat output says postgres is at stage LISTEN for requests at All this started happening when I came up with the new firewall config. I was of the idea that the following line

-A INPUT -i lo -j ACCEPT

should take care of local connections from tomcat webapp to postgres, but looks like it doesn't. I need to know what is it in the firewall config that I need to change to allow the connections back again.

  • your postgres port is open but localy , if you have remote user and want remote login can't do it. Commented Sep 29, 2013 at 18:50
  • postgres port is open locally and I surely don't want remote users to login into to it for obvious reasons. The webapp tries to connect to postgres locally too. Commented Sep 30, 2013 at 2:19

1 Answer 1


Port forwarding from a standard NIC (eth0) to a loopback interface (lo) is disabled by default. You must enable this feature:

$ sudo sysctl -w net.ipv4.conf.eth0.route_localnet=1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .