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.
telnet remote-host 5432
. If it can't get through then that's the root cause.