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. – PersianGulf Sep 29 '13 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. – The Governor Sep 30 '13 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.