Enable Remote Access To PostgreSql 9.5 DB

Enable Remote Access To, We have installed PostgreSQL 9.5 Server on our machine. The procedure is same for all version of PostgreSQL server.

By default, Postgresql server allows access to client locally using socket.

Check Out : Installation of PostgreSQL Database Server

Step 1 : if you successfully configured PostgreSQL server then you will see all the files inside data directory as shown in figure

ls /var/lib/pgsql/data/

Step 2 : Now you have to configure postgresql.conf file

By default settings shown in below figure

Changed Listen address to ‘*’

It will allow server to listen request to all address.

Check Out : Error “ Job For Postgresql.service failed ”

Step 3 :  Now visit to this file location to allow host to access database

vim /var/lib/pgsql/data/pg_hba.conf

This will allow any host to access the PostgreSQL database with encrypted password.

Step 4 : Configure firewall which will allow PostgreSQL to listen on Port number 5432

firewall-cmd –permanent –add-port=5432/tcp

firewall-cmd –reload

Step 5 : Restart the PostgreSQL service

systemctl restart postgresql

Check Out : Add Port in firewall

Step 6 : Test the remote connection to PostgreSQL

psql –h 192.168.1.10 –u postgres

You will see postgres shell

You’re done

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here