Automatically reconnect SSH tunnel DB connection


We connect Metabase to a database via an SSH tunnel. Whenever the database goes down (for various reasons) we need to manually reconnect the database. Is there any way to automate this? Via the API (we have looked but couldn’t find anything) or via some other means?


Hi @jcandiloro
Currently, there’s several problems with the built-in SSH tunnel, so I would recommend that you create the tunnel manually outside of Metabase:

H @flamber,
Thanks for the reply. Do you happen to know if there are plans to resolve this problem?

@jcandiloro Yes, but there’s 1700 other issues, and like many other issues, it turns out it’s more complicated than expected.
Also related issue:

@flamber Just to expand on @jcandiloro question. The built-in SSH tunnel seems to work fine overall, except it doesn’t reestablish the connection if DB goes off-line. To make it work again we need to go to Metabase and press the “Save changes” button on Database config page. That seems like a little thing to make it work perfectly. For example an API that would allow us to press that “Save changes” button via a script. Would you have any ideas how to achieve that ?

@tomn This is the API, when clicking “Save changes”:
The best way to learn the API, is to just use Metabase while having your browser developer Network-tab open and looking at the request, and what data is being send/received.

Thanks @flamber.