I am using Metabase with a PostgreSQL database on a host that only allows local database access, but I can SSH to the database server. Before Metabase supported SSH tunnels natively, I would manually create one before launching Metabase. For example:
- Metabase running on data.example.com
- Postgresql running on remotehost.com:5432 (only allows connections from localhost)
- I run
ssh firstname.lastname@example.org -p 2234 -L 5432:127.0.0.1:5432 to open the tunnel
- I launch Metabase and configure a PostgreSQL database at
- Everything works great.
I am now trying to use Metabase’s native SSH tunnel feature. I shut down my manual SSH tunnel and reconfigure the database like so:
- Database type: PostgreSQL
- Host: 127.0.0.1
- Port: 5432
- SSH tunnel host: remotehost.com
- SSH tunnel port: 2234
All usernames and passwords are correct. When I try to save the database configuration, I get this error:
org.postgresql.util.PSQLException: Connection to remotehost.com:36683 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
It seems like after creating the tunnel, Metabase is trying to open the connection to the remote host when it should be opening a local connection (that then gets forwarded through the tunnel). Am I configuring this wrong?