Could not connect to server: connection refused is the server running on host and accepting tcp/ip connections on port 5432?

In this article let’s discuss about Could not connect to server: connection refused is the server running on host and accepting tcp/ip connections on port 5432?. Let’s go through the following methods without any delay.

Method 1:

cd /etc/postgresql/9.x/main/
------- open file named postgresql.conf
sudo nano postgresql.conf
------- add this line to that file
listen_addresses = '*'
------- then open file named pg_hba.conf
sudo nano pg_hba.conf
------- and add this line to that file
host  all  all 0.0.0.0/0 md5
------- restart your server
sudo /etc/init.d/postgresql restart

Hope the above solution works.

Realted Posts : What is default gateway -linux