Remote access to PostgreSQL

By default, PostgreSQL is configured to listen on the local address only.  To enable access remotely we need to tell PostgreSQL to “listen” on the public facing address.  With elevated privileges, we need to modify the postgresql.conf.

> sudo nano postgresql.conf

In the “CONNECTIONS AND AUTHENTICATION”  section, you should see a key value pair like this one

#listen_addresses = ‘localhost’

We need to uncomment that setting and add the public ip of your server or open it up completely.

listen_addresses = ‘*’

or

listen_addresses = ‘localhost’,’192.168.1.1′

When you are ready, restart the server to start the server listening on other IPs.

> sudo service postgresql restart 

Once the server has restarted, you should be able to access the database remotely.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s