10

Even though it might sound related to this question, it isn't, because I'm intreseted in the use of unix sockets instead of TCP/IP ones.

However, I am unable to connect to a remote PostgreSQL database using unix sockets and an ssh tunnel with pgAdmin4. pgAdmin always claims a refused connection by the server and asks for a password, which makes me wonder. When sshing into the server and using psql a connection can be made just flawlessly using the unix socket (/var/run/postgresql). Is there anything special that needs to be set to allow such a setup, or might this even be a bug in pgAdmin itself? I'd appreciate any ideas to solve this problem without having to resort on TCP/IP connections on the remote side.

I also post some screens from my current config:

connection tab

ssh tunnel tab

1 Answer 1

9

That should work fine with the correct ssh command.

To forward from a local Unix socket to a remote one runs

ssh -L /tmp/.s.PGSQL.5555:/var/run/postgresql/.s.PGSQL.5432 -N laurenz@dbserver

Then you would use host /tmp and port 5555 to connect.

To forward a local TCP socket to a remote Unix socket, run:

ssh -L 5555:/var/run/postgresql/.s.PGSQL.5432 -N laurenz@dbserver

Then you would use host 127.0.0.1 and port 5555 to connect.

4
  • Where comes that limitation from? Doesn't a ssh tunnel work similar to a fully fledged ssh session?
    – Migsi
    Commented Nov 2, 2020 at 13:26
  • Oops. I researched and saw that I was wrong. Answer updated. Commented Nov 2, 2020 at 13:43
  • It looks like my assumption about ssh tunnel beeing a fully fledged session was wrong too. Thank you for the update, this seems to be a very simple solution and might work until pgAdmin adds in native support for it.
    – Migsi
    Commented Nov 2, 2020 at 13:47
  • Accepted, works flawlessly :)
    – Migsi
    Commented Nov 2, 2020 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.