8

I am running postgresql in WSL Ubuntu on windows. Everything is up to speed, my data is loaded and I wish to access the database through some graphical interface. I was thinking pgadmin4.

Is it possible to accomplish this through a windows install of pgadmin4? I installed pgadmin4 on windows and tried to connect the traditional way in the GUI through localhost but am not getting a connection. I figure there may be a special method here.

LoF10
  • 1,907
  • 1
  • 23
  • 64
  • 3
    https://stackoverflow.com/a/54192456/8168950 Follow the link above. That might help. – Sajitron Jun 01 '19 at 22:14
  • This should help. Newer builds of windows 10 have made it possible for wsl2 to connect via localhost https://chloesun.medium.com/set-up-postgresql-on-wsl2-and-connect-to-postgresql-with-pgadmin-on-windows-ca7f0b7f38ab – Jhirschibar Mar 08 '21 at 18:44

3 Answers3

0

For everyone else stumbling across this: The best way to do this (that I know of) is to SSH into your local WSL and then configure the SSH in pgAdmin to that.

I have yet to figure out, how to use this remotely.

TheLexoPlexx
  • 117
  • 13
0

As long as postgres is running within your wsl2 instance (check with sudo service postgresql status) then within PgAdmin 4 (running in windows), all you need to do is click to "Register" a new server.

Then, while entering the Connection data, set host to localhost and port to 5432 (unless you specified unique port within your postgres instance when creating in wsl2.

See this answer for more detail

Jhirschibar
  • 215
  • 1
  • 3
  • 16
-3

There is no special way needed, you should be able to get a connection. Just like your dev http ports are exposed to your browser on Windows, your db port should too.

I had to manually add localhost to pg admin though which is a bit weird.

Make sure your db service is up and running on Ubuntu, sometimes the db service is killed for no reason.

To see if your PostgresSQL service is up or not:

sudo service postgresql status

If it's not, start the service:

sudo service postgresql start
yodabar
  • 4,651
  • 2
  • 33
  • 38
Charming Robot
  • 2,460
  • 2
  • 17
  • 34