unable to connect to server postgresql using pgadmin

Hi Guys, Welcome to Proto Coders Point. This article is on the solution i.e “pgadmin unable to connect to server”, “could not connect to server: Connection refused”.

Here are 2 issue you may face while connecting to postgresql server using pgadmin.

1. Could not connect to server: Connection refused

pgadmin postgresql connection refused solution

2. Unable to connect to postgres server at IP port 5432 failed: timeout expired

pgadmin postgresql connection timeout expired

Solution

Solution 1 – Check if postgresql server is active

run below cmd to check postgresql status

sudo service postgresql status
postgresql check status

If it InActive, restart postgresql

sudo service postgresql restart

Solution 2: enable postgres to allow remote connections

By default postgresql remote connection is disabled for globally accessing db using server IP & can only by accessed locally on server itself.

ss -nlt | grep 5432

This should give response as running on global 5432, i.e. 0.0.0.0:5432. This means that psql is now enabled for remote access.

check postgresql listening post

Check out this article to enable postgres to allow remote connections.


Solution 3: All PostgreSQL port 5432 Inbound rules on cloud instance

Check if you have Added Inbound rules for allowing incoming traffic to port 5432, Add Inbound rules, as shown in below image.

add inbound rules on aws server for port 5432

After postgres configuring as soon in above steps, you will sure be able to connection postgresql server using pgadmin.

pgadmin postgresql connect