Connect to PostgreSQL via a ssh tunnel using Cygwin I would like to connect to a Postgres server installed on a remote server using an ssh tunnel.
I have Windows so I use cygwin for SSH.

I do the following on cygwin:

# Create the tunnel
ssh -f user@remote_server -p ssh_port -L 5433:127.0.0.1:5432 -N


On pgAdmin, I set the host to localhost and the port to 5433 as well as the username/password/db.

When I try to connect, it is running, and then it displays an error message:  

Error connecting to the server: server closed the connection unexpectedly.


On cygwin, I see this message:

Write failed: Broken pipe


The ssh process has actually been killed so I guess it crashed? But why?

How could I get more information to know what the problem is and especially where (pgadmin or ssh tunnel on cygwin...) ?

Thanks
I was finally able to make it work by removing the -f option when creating the SSH tunnel.

For an unknown reason, the error appears when using the -f option but it works fine otherwise and I can connect via pgAdmin using the SSH tunnel.