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

February 25, 2018 2.8k views
PostgreSQL Ubuntu Ubuntu 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?

Thanks!

1 Answer

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@111.111.111.111

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.
Have another answer? Share your knowledge.