Posted by: pvibeesh on: October 28, 2008
A. First make sure PostgreSQL server has been started to remote server.
# /etc/init.d/postgresql start
If it is running and you get above error, you need to add enable TCP/IP support. By default, the PostgreSQL server only allows connections to the database from the local machine or localhost. This is a security feature.
You need to open file called /var/lib/pgsql/data/pg_hba.conf. Login as postgres user using su command:
$ su - postgres
$ vi /var/lib/pgsql/data/pg_hba.conf
Now append following line. Let us say you would like to give access to 192.168.0.0/24 network:
host all all 192.168.0.0/24 trust
Please replace 192.168.0.0 and 255.255.255.0 to reflect the actual network IP address range of the clients system in your own network.
Save close the file.
You need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf
$ vi /var/lib/pgsql/data/postgresql.conf
Now bind and open TCP/IP port by setting tcpip_socket to true:
tcpip_socket = true
Save and close the file.
Restart the PostgreSQL server with the following command
# /etc/init.d/postgresql restart
This will open default port 5432.
Use psql command from client system as follows:
psql -h PostgreSQL-IP-ADDRESS -U USERNAME -d DATABASENAME
Connect to remote server by IP address 192.168.0.3 and login using testuser to connect to testdb database, use:
$ psql -h 192.168.0.3 -U testuser -d testdb
Where,
When your are trying to connect a remote pgsql db on a Suse Linux 9 or others, It did not have the tcpip_socket parameter in postgresql.conf
To overcome this, I had to uncomment the following settings:
#—————————————————————————
# CONNECTIONS AND AUTHENTICATION
#—————————————————————————
# – Connection Settings -
listen_addresses = ‘*’
port = 5432
Recent Comments