Wednesday, May 9, 2012

Cannot Connect PostgreSQL Remotely

could not connect to server: Connection refused Is the server running on host "......" (......) and accepting TCP/IP connections on port ....?

Solution
========
sudo vi /etc/postgresql/8.4/main/postgresql.conf

listen_addresses = '*'
port = 5432



After changing this file, you need to restart the server process to make the setting effective.

sudo service postgresql start



Note from pgadmin3
===================
For security reasons, PostgreSQL does not listen on all available IP addresses on the server machine initially. In order to access the server over the network, you need to enable listening on the address first.

For PostgreSQL servers starting with version 8.0, this is controlled using the "listen_addresses" parameter in the postgresql.conf file. Here, you can enter a list of IP addresses the server should listen on, or simply use '*' to listen on all available IP addresses.


Other Related Info
===================
sudo vi /etc/postgresql/8.4/main/pg_hba.conf

to allow connections from any remote address.
host all all 0.0.0.0/0 md5

psql -U {username} -h {hostname} -D {database_name}


thanks http://kb.mediatemple.net/questions/1237/How+do+I+enable+remote+access+to+my+PostgreSQL+server%3F#dv

No comments:

Post a Comment