PostgreSQL: How to Allow Remote Connection to Connect Database

I have installed and configured PostgreSQL in one of our client computer and found that by default TCP/IP is not allowed.

When a client machine tried to connect PostgreSQL Server, it got a error like “psql:could not connect to server:Connection refused”.

If you require to connect your all clients with PostgreSQL server, you should perform below two actions.

Add client IP-Address range into pg_hba.conf :
pg_hba.conf is a configuration file which is controlled Client Authentication. This file automatically installed when the data directory is initialized.

Below is a default entry in pghba.conf file.

In our example, we have one client, IP-Address which is “”. If you require to connect this client with PostgreSQL Server, please add below entry in pghba.conf and after that save this file and restart PostgreSQL Service.

Another method is to change listen_addresses parameter in postgresql.conf :

In the PostgreSQL configuration file (postgresql.conf), by default listen address is “localhost” like,

Please change this parameter value from ‘localhost’ to ‘*’ so that all clients can connect from different networks.

Anvesh Patel

Leave a Reply

5 Comments on "PostgreSQL: How to Allow Remote Connection to Connect Database"

Notify of
Sort by:   newest | oldest | most voted

Very nice article. I definitely love this site.
Continue the good work!


Thank you for sharing this…


thank you anvesh sir…


thanks for sharing this


thank you anvesh sir šŸ™‚