How do you remote connect with PgAdmin 4 to a postgresql on a droplet?

Posted February 25, 2018 24.4k views
UbuntuPostgreSQLUbuntu 16.04

How do you guys connect with PgAdmin 4 to postgres running on a ubuntu-droplet? Can you do it over SSH or do you need to setup a VPN or something like that? All info is appreciated since I cant find real good articles on it, but I just assume not everyone is working through the terminal?


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.

Submit an Answer
2 answers

The most secure way to do this is probably to configure an SSH tunnel. It will securely send traffic from the Droplet to your local machine without needing to expose the database publically.

Assuming you already have SSH set up, from your local machine run:

ssh -L 63333:localhost:5432 user@

Let’s break that command down a bit:

  • 63333 is the port you want to be able to access Postgresql on locally. It doesn’t need to be that number, it is just for example.
  • 5432 is the port that Postgresql is running on the Droplet. That is the default port used.

Now when you set up PgAdmin, you can use localhost for the “Host” setting and 63333 for the port.

For more information on how SSH tunneling works, check out:

In this article, you'll learn how to create a safe, encrypted tunnel between your computer and your VPS along with how to bypass limits in a corporate network, how to bypass NAT, etc.

Best choice for connecting PGAdmin to server is SSH-tunnel using Public key authentication (Identity file) for SSH connection. PGAdmin 4.4 supports ssh-tunnel out of the box. But there is a small issue with supported public key formats. By default newer versions of ssh-keygen generate key in RFC4716 format, but PGAdmin supports only PEM. So you need to add -m PEM option when generating your key.


ssh-keygen -m PEM -t rsa -b 4096

More information here