SSH tunneling while connecting to MongoDB does not work

I am running metabase docker deployment in production environment and would like to connect a mongodb atlas cluster to it. If I whitelist all IPs in Mongodb atlas, I am able to connect with a connection string obtained as written in the documentation. But when I try to use ssh tunneling while connecting to the mongodb atlas (now only whitelisted ip is the ip of ssh tunnel host), it doesnot work. Here are the logs:
[5c20bb0d-f909-484c-bffc-829572593a0a] 2022-01-12T08:52:39+05:30 ERROR metabase.api.database Cannot connect to Database
java.lang.NullPointerException
[5c20bb0d-f909-484c-bffc-829572593a0a] 2022-01-12T08:52:39+05:30 ERROR metabase.driver.util Database connection error
java.lang.NullPointerException
[5c20bb0d-f909-484c-bffc-829572593a0a] 2022-01-12T08:52:39+05:30 ERROR metabase.api.database Cannot connect to Database
java.lang.NullPointerException
[5c20bb0d-f909-484c-bffc-829572593a0a] 2022-01-12T08:52:39+05:30 DEBUG metabase.server.middleware.log POST /api/database 400 3.4 ms (0 DB calls)
{:valid false, :dbname nil, :message nil}

Can someone please tell me what the problem is? Thank You.

Hi @aaftab
It's hard to tell with that little amount of logs. You would need to check the logs on the SSH host and Mongo to see where the connection gets to.
You can use your own external tunnel instead of the one builtin to Metabase:
https://www.metabase.com/docs/latest/administration-guide/ssh-tunnel-for-database-connections.html#running-ssh-directly