Connection issues through SSH Tunnel to Atlas Serverless

Hi I’m facing a problem when a I try to connect through a SSH Tunnel and a Bastion Host. I want to connect to my serverless instance on Atlas (AWS as Cloud Provider). I’ve created a VPC Endpoint to connect to Atlas in a more private way, I tested the connectivity and it works. Im using the connection string (mongodb+srv) provided by the Atlas UI, and can connect using the SSH Tunnel using the Tool MongoDB Compass. I can connect using the connection string if i connect directly from the bastion host. I have problems if a create a SSH Tunnel and use the connection string in my Node.js app with Mongoose. What Im doing wrong?
The connection string is:
mongodb+srv://user:password@database-pe-0.vyi9q.mongodb.net/dev
I know that this is resolved to an IP Address, and I change that IP Address to localhost, so this would be forwarded through the SSH Tunnel, but dont worked.
ssh -L 27017:10.0.4.19:27017 ec2-user@ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com -i key.pem
Is there a way to achieve this without installing any deps in my app?
I want to connect from my local environment where i have a nodejs app to a private mongodb database (Atlas) using SSH Tunnel but i cant

1 Like

I have exactly the same issue. Have you had any luck resolving it?