On my local machine I have an SSH tunnel setup for postgres like so:
ssh -fNL 5434:127.0.0.1:5432 user@host
Then running psql -h localhost --port 5434 works just fine and dandy, giving me a postgres terminal.
Then, on my VM (VirtualBox), I have the host vmhost defined as 192.168.56.1. SSHing into vmhost works fine- connects to the host.
But, running from the vm psql -h vmhost --port 5434 yields:
psql: could not connect to server: Connection refused
Is the server running on host "vmhost" (192.168.56.1) and accepting
TCP/IP connections on port 5434?
Is there some kind of SSH tunnel forwarding magic thing that’s not happening here? How can I allow this to work?
You want to use the
-goption when opening the SSH connection. Otherwise, only localhost itself can connect to the tunnel.