Connect to PostgreSQL with pgAdmin3

This guide will show you how to configure postgres for external connections. Since its good practice to have your dbms on a seperate machine. This guide will help you configure your remote dbms server to be connected to from an external reasource. You need to do 3 things to make ensure that this works:

  • enable networking in PostgreSQL
  • enable client authentication
  • make sure you are not blocked by firewall rules

Enable Networking in PostgreSQL

modify postgresql.conf change

# change
listen_addresses = 'localhost'
#
# to
#
listen_addresses = '*'
#
# or a list of allowed addresses
#
listen_addresses='192.168.1.12 192.168.1.35'

Enable Client Authentication

To Enable Authentication: modify pg_hpa.conf change

# append the following to give access to the 192.168.0/24 network
host all all 192.168.1.0/24 trust

Make sure you are not blocked by firewall rules

Now you need to make sure that there is nothing in your firewall configuration that will keep clients from connecting on this tuple: ip/port pair. When your firewall is disabled your output from a iptables listing should be as follows:

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination   

Warning: this guide does not take into consideration security concerns. Its really intended to guide developers on private networks how to configure there resources.

Thats it, now fire up pgAdmin3 and connect to your remote PostgreSQL server.

Reference: