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

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?


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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:

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