Allow connection to PostgreSQL server outside localhost

If PostgreSQL is set to only listen and allow connections from localhost ( then you can change the configuration to allow other or all IP addresses to connect.

First we will need to make sure PostgreSQL is listening for connections outside of local networking in the main configuration, which should be located somewhere such as /etc/postgresql/9.x/main/postgresql.conf (where 9.x is whichever version you have installed) so just uncomment the listen addresses line

However to make sure that the IP address you’re connecting from is also allowed you’ll need to change /etc/postgresql/9.x/main/pg_hba.conf to either add each IP address or set it to all (

Depending on your operating system you will need to restart the PostgreSQL server (for example service postgresql restart)

1 comment