Remote PostgreSQL connection with iptables

October 12, 2011 | In: database, postgres, PostgreSQL

I followed this wonderful tutorial about setting up the machines involved in the remote PostgreSQL connection on cyberciti .

But after that i still have one problem, the firewall is blocking the port 5432.

Say your client machine’s IP address is and your server where’s your database is located at 987.65.43.21

On your database server, add this iptables rule:

# iptables -I INPUT -i eth0 -p tcp --dport 5432 -s -j ACCEPT

And on your client machine, try to connect:

psql -h 987.65.43.21 -d your_dbname -U your_db_user

And your done!

NOTE: I tried the ‘-A’ instead of ‘-I’ and for some reason due to the order of rules, firewall still blocking it so you won’t still be able to connect.

Comment Form