Question

Unable to Remotely Connect to Postgresql Database(s) - Already Tried to Setup As Suggested In Many Other Posts

Posted January 27, 2020 298 views
DigitalOceanPostgreSQLUbuntu 18.04Databases

I have installed Unbuntu on a droplet as well as a PostGresql server setup on it as well.

I was however, able to connect in the terminal on my droplet with this: psql -h [ipaddress] -d [nameofthedatabase] -U [username]....

I am unable to remotely connect to my Postgresql database(s) via pgAdmin4 or Azure Data Studio. I have been researching for the past week on what the issue is and still have not had any luck…

I have changed the required config files as suggested in many other topics exactly like mine.

  1. I have a db user that has been granted all privileges to the database I want to dev on.

  2. I have changed my pg_hba.conf file so that it accepts all IPs’ both for IPV4 and IPV6. For Example: 0.0.0.0/0 and ::/0

  3. I have changed the postgresql.conf so that the listening addresses = ’*’ (yes, its uncommented).

  4. I have also ran the script for the firewall for port 5432.

When I try to connect to the database using Azure data studios I keep getting:

“Is the server running on host”...“ and accepting TCP/IP connections on port 5432?”

or when I try to connect in pgAdmin4 it just says I am unable to connect

Thus, when I run netstat -nlt I can see that can’t be rue becasue of this:

tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN

Any ideas on whats going on here..?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

This sounds like your firewall is blocking the connections. If you run sudo ufw status do you see a rule allowing access on port 5432?

If not, make sure to allow it with the following:

ufw allow 5432/tcp

Also did you restart your PostgreSQL service after making those changes?

Submit an Answer