Connect to MySQL & Postgres over SSH Tunnel


Hi All,
Is it currently possible to have a MySQL or Postgres data source that is connected to via an SSH tunnel?

Add ssh gateway setting to MySQL(Amazon RDS)
オンプレのredash環境からAmazon RDSへの接続について

Yes, use ssh to create the tunnel first then connect redash to the tunneled port.

ssh -N -Llocalport:remotedbhost:remoteport user@sshhost

ssh -N -L3307:localhost:3306

You can specify multiple -L parameters to map MySQL and Postgres

Then simply connect to port 3307.

I have this running as an upstart job in on my redash machine to keep the tunnel open 24/7.


I would also look into autossh as a way to reliably keep the tunnel open.


Thanks both, I wasn’t sure if I was missing an option in the GUI that would have redash open the tunnel, use it for a query & close it afterwards, but leaving it open is fine :slight_smile:

Thanks for pointing out autossh as well, I’d never seen it before & it looks awesome!


Is there a way to have the SaaS version talk to our postgres database? I presume the described mechanism would only work if we were running our own redash.



There is no UI to control it, but we can setup the tunnel for you if needed.


Is there any good way of doing this with the docker deployment. Especially the workers.


I have the same issue but don’t have ssh access to my database server. However, I can connect to mysql from another server in the same network. how should I proceed? I did this:

autossh -N root@IP -C

I get this error:

Connection Test Failed:
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)


Did you find a workaround @hadifarnoud or @Slind ?