Enable Remote Access To PostgreSql 9.5 Database Server On Redhat 7

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 the Postgresql server in Linux.

Enable Remote Access To Postgresql 9.5 DB:

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

ls /var/lib/pgsql/data/

Enable Remote Access To

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

By default, These are the configuration in the file.

postgresql server access

Changed Listen to address to ‘*‘ and remove the ‘#‘.

postgresql server remote access

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. 

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

This will allow any host to access the PostgreSQL database with an encrypted password. I have allowed all the networks.

allow connections to postgresql

Check Out: How To Install Podman and Run Container On Linux 8

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

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

allow postgresql remote connections

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 the Postgres shell.

You’re done allow connections to postgresql remote

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

2 thoughts on “Enable Remote Access To PostgreSql 9.5 Database Server On Redhat 7”

Leave a comment