Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect MongoDB Compass to AWS DocumentDB using SSH tunnel

I am new to mongoDB trying to setup tools for my new project. Most of my infrastructure run on AWS so i prefer to use AWS documentDB. I manage to connect to documentDB from EC2 both via mongo client or NodeJS aplication. but it would be good to mange documentDB from my Windows workstation using MongoDB Compass.

As we know, we can not direct connect any mongo client from outside AWS to DocumentDB Connecting to an Amazon DocumentDB Cluster from Outside an Amazon VPC
so we need SSH tunnel through EC2. I try many options but still fail... below are most likely 2 options:

Option 1: Connect using MongoDB Compass SSH tunnel

Error: unable to get local issuer certificate

both RDS-COMBINED-CA-BUNDLE.PEM and SSH Key already supplied so which one unable to get?

as red highlight on SSH port, I also tried to open another SSHD port on server and tried to connect using second port but still failed.

enter image description here enter image description here

Option 2: Connect using Putty SSH tunnel

Error: Hostname/IP does not match certificate's altnames...

since MongoDB Compass need to connect to locathost to get into tunnel and i still can not find the way to supply --sslAllowInvalidHostnames options.

enter image description here enter image description here enter image description here

So, what i can do to get around this ?

MongoDB Compass: 1.25.0

like image 590
Apiwat Jarruwattanachai Avatar asked Sep 04 '25 03:09

Apiwat Jarruwattanachai


1 Answers

As of Jan 2022 MongoDB Compass does not support sslInvalidHostNameAllowed=true in the connection builder form, this is the parameter you are missing in order to connect to AWS DocumentDB while ssh tunneling to a machine inside the same VPC of the database itself.

I used Studio 3T and it worked perfectly. You could create the connection string yourself or try other GUI.

Edit Jan 2023: I just gave a try to compass again and it seems they now support sslInvalidHostNameAllowed flag through the UI, you could still change manually the connection string but then any UI interaction would overwrite it.

like image 144
David Mauricio Avatar answered Sep 07 '25 17:09

David Mauricio