MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

Connecting to mongodb via ssh tunnel in Node.js

I’m trying to connect to my mongodb instance through a ssh tunnel. I’m able to connect when using the mongo cli with the following command

mongo “mongodb://:@127.0.0.1:27018/?ssl=false”

But when i use npm library mongodb and calling

     MongoClient.connect(
    "mongodb://<username>:<password>@127.0.0.1:27018/?ssl=false",
    {
      ssl: false,
      sslValidate: false,
      useNewUrlParser: true,
      useUnifiedTopology: true,
    }

I get a connection timeout.
Can anyone help me out on this one?

Just for fun, have you tried making it localhost instead of 127.0.0.1?