How to enable remote access to your PostgreSQL server?

Article ID: 1133 
Last Review: Oct,6 2008
Author: APPLIES TO:
  • Plesk for Linux/Unix

Resolution

The default configuration of PostgreSQL does not allow incoming connections from external machines. This implies that no external application can access your databases.

To make it available the three steps have to be done:

1. You have to make PostgreSQL listening for remote incoming TCP connections because the default settings allow to listen only for connections on the loopback interface. To be able to reach the server remotely you have to add the following line into the file $PGSQL_DATA_D/postgresql.conf:

For Postgres 8.x:
listen_addresses = '*'

For Postgres 7.x:
tcpip_socket = true

2. PostgreSQL by default refuses all connections it receives from any remote address, you have to relax these rules by adding this line to $PGSQL_DATA_D/pg_hba.conf:

host all all  0.0.0.0/0 md5

This is an access control rule that let anybody login in from any address if he can provide a valid password (the md5 keyword). You can use needed network/mask instead of 0.0.0.0/0 .

3. When you have applied these modifications to your configuration files you need to restart PostgreSQL server. Now it is possible to login to your server remotely, using the username and password.


Subscription for this article changesSubscription for this article changes

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
* - required fields