Enable Remote Access To Postgresql 9.5 DB
Enable Remote Access To, We have installed PostgreSQL 9.5 Server on the Linux machine. The Installation procedure is the same for all versions of the PostgreSQL server. you can allow remote access connections to Postgresql server in Linux.
By default, the Postgresql server allows access to a client locally using a socket.
Check Out: Installation of PostgreSQL Database Server
Step 1: if you have successfully configured PostgreSQL server, you will see all the files inside in this data directory as shown in figure
Step 2: Now you have to configure postgresql.conf file
By default, These are the configuration in the file.
Changed Listen to address to ‘*’ and remove the ‘#’.
It will allow the server to listen to requests to all addresses.
Check Out: Error “ Job For Postgresql.service failed ”
Step 3: Now you need to define the host and only they can connect to this server.
This will allow any host to access the PostgreSQL database with an encrypted password. I have allowed all the networks.
Step 4: Configure firewall that will allow PostgreSQL to listen on Port number 5432
firewall-cmd –permanent –add-port=5432/tcp
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 allow connections to postgresql remote