Friday, 5 February 2016

PostgreSQL server allow to connect from remote clients



Step 1: You have to make PostgreSQL listening for remote incoming TCP connections because the default settings allow listening 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 /etc/postgresql/9.3/main/postgresql.conf:
listen_addresses = '*'


Step 2: PostgreSQL by default refuses all connections it receives from any remote address; you have to relax these rules by adding this line to /etc/postgresql/9.3/main/pg_hba.conf:
host all all 192.168.0.0/24 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 192.168.0.0/24.

Step 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.

Step 4: To start PostgreSQL server in Ubuntu/debian  /etc/init.d/postgresql stop and  /etc/init.d/postgresql start. 

No comments:

Post a Comment