PostgreSQL remote connection through pgAdmin4


I recently started developing my droplet, and I’m quite new to this. Im trying to establish a remote PostgreSQL connection through pgAdmin4. The problem is, when I try to connect through pgAdmin4 by going through the Add new server and clicking Save button, it does nothing, sort of freezes.

My droplet is running on Ubuntu 16.04, I followed an instruction on how to set up PostgreSQL on ubuntu 16.04 on Django, installed all the necessary components, set up an environment, and a project, to the point where I even managed to create a db and a table. I even edited the file:

DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.postgresql_psycopg2’, ‘NAME’: ‘…’, ‘USER’: ‘…’, ‘PASSWORD’: ‘…’, ‘HOST’: ‘’, ‘PORT’: ‘5432’, I even added that to the end of the page: STATIC_ROOT = os.path.join(BASE_DIR, ‘static/’)

And, ofcourse changed the ALLOWED HOSTS = [‘…’] to with my droplet ip aswell.

Then I edited both postgresql.conf and pg_hba.conf aswell. The listen_address is set to ’ * ’ and it is uncommented

The pg_hba.conf file:

local all postgres peer


“local” is for Unix domain socket connections only

local all all peer

IPv4 local connections:

host all all md5

IPv6 local connections:

host all all ::1/128 md5

I also allowed port 5432 through my firewall.

Any ideas why I can’t set up a connection with pgAdmin?



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

I would strongly recommend against setting up your database server to listen publicly as it can open you up to potential attacks or attempts to compromise your server.

Rather than making PostgreSQL configuration changes you can use the SSH Tunnel option in pgadmin. With this type of a connection you would add your ssh connection details (user/pass or user/key) and pgadmin will make an ssh connection to your server and then connect to your database as “localhost”.