3

I have PostgreSQL installed on a remote host running Debian 8. I must use a ssh tunnel via a proxy server to connect to this remote. I have no problems:

  • in connecting via ssh on port 22,
  • in running psql locally when connected on the remote host.

But, I can't run psql via the tunnel. What I did:

1) Create the tunnel with -vvv option:

ssh proxy-user@proxy-host -L localhost:2222:remote-host:5432 -N -vvv

2) Try to run psql via the tunnel:

psql -h 127.0.0.1 -p 2222 -U user db

The connection is refused, here is the output of the first command:

debug1: Connection to port 2222 forwarding to XX.XX.XX.XX port 5432 requested.
debug2: fd 7 setting TCP_NODELAY
debug2: fd 7 setting O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
debug3: send packet: type 90
debug3: receive packet: type 92
channel 2: open failed: connect failed: Connection timed out
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: direct-tcpip: listening port 2222 for XX.XX.XX.XX port 5432, connect from 127.0.0.1 port 35206 to 127.0.0.1 port 2222, nchannels 3
debug3: channel 2: status: The following connections are open:

Any ideas ? (please can explain in details what commands try, I'm not used to debug network problems). Thanks a lot.

4
  • Check PostgreSQL is configured to listen only on localhost. Feb 16, 2017 at 18:23
  • Note that you get "Connection timed out" as opposed to "Connection refused". Generally the first means it gets firewalled, the second means no listener at the host/port. If you can get a shell on proxy-host, try telnet remote-host 5432. If it can't get through then that's the root cause. Feb 17, 2017 at 11:33
  • @FedericoSierra: I checked, in postgresql.conf, listen_adresses is set to '*', and in pg_hba.conf, the IP of the proxy are allowed.
    – scandel
    Feb 17, 2017 at 13:55
  • @DanielVérité: unfortunatelly I have no shell access on the proxy server, so I can't check your point. I guess I have to contact the sysadmin to test the firewall hypothesis. Thanks for your advice.
    – scandel
    Feb 17, 2017 at 13:59

0

You must log in to answer this question.

Browse other questions tagged .