This article is half-done without your Comment! *** Please share your thoughts via Comment ***
I installed and configured PostgreSQL in one of our client computers and found the problem of TCP/IP.
When a client machine tried to connect the PostgreSQL Server, it got an error like “psql:could not connect to server:Connection refused”.
If you need to the connect all clients with PostgreSQL server, you should perform the below two actions.
Add client IP-Address ranges into pg_hba.conf :
pg_hba.conf is a configuration file which controls the Client Authentication. This file automatically installed when the data directory is initialized.
Below is a default entry in pghba.conf file.
1 2 3 4 |
# IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 |
In our example, we have a client, IP-Address which is “10.0.0.12”. If you require connecting this client with PostgreSQL Server, please add below entry in the pghba.conf and after that save the file and restart PostgreSQL Service.
1 |
host all all 10.0.0.12/24 md5 |
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,
1 |
listen_addresses = 'localhost' |
Please change this parameter value from ‘localhost’ to ‘*’ so that all clients can connect from different networks.
1 |
listen_addresses = '*' |