Configure PostgreSQL to allow remote connection.

Channel Avatar
Comment
X
Share
Configure PostgreSQL to allow remote connection.
Configure PostgreSQL to allow remote connection.
——————————————————————————————————————————————
By default PostgreSQL is configured to be bound to /”localhost/”.
——————————————————————————————————————————————
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3737 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
As we can see above port 5432 is bound to 127.0.0.1. It means any attempt to
connect to the postgresql server from outside the machine will be refused.
——————————————————————————————————————————————
Configuring pg_hba.conf
……………………………………………………………………………………………………………………………….
In order to fix it, open pg_hba.conf and add following entry at the very end.

host all all 0.0.0.0/0 md5
host all all ::/0 md5
……………………………………………………………………………………………………………………………….
OR
……………………………………………………………………………………………………………………………….
host all all 127.0.0.1/32 scram-sha-256
host all all 0.0.0.0/0 scram-sha-256
_____________________________________________________________________________________
2023

Take the opportunity to connect and share this video with your friends and family if you find it useful.

Read Also

Leave a Reply

Your email address will not be published. Required fields are marked *