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.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

3 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…