Node JS connection error

Hello,

I am getting following error

 const timeoutError = new error_1.MongoServerSelectionError(`Server selection timed out after ${options.serverSelectionTimeoutMS} ms`, this.description);
                                     ^

MongoServerSelectionError: C0A7BA57F87F0000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1605:SSL alert number 80

when I am following the official doc to connect mongodb in NodeJS

const client = new MongoClient(uri, {
  serverApi: {
    version: ServerApiVersion.v1,
    strict: true,
    deprecationErrors: true,
  }
});
async function run() {
  try {
    // Connect the client to the server	(optional starting in v4.7)
    await client.connect();
    // Send a ping to confirm a successful connection
    await client.db("admin").command({ ping: 1 });
    console.log("Pinged your deployment. You successfully connected to MongoDB!");
  } finally {
    // Ensures that the client will close when you finish/error
    await client.close();
  }
}
run().catch(console.dir);
}

I have checked previous answers to this question and double checked that my ip address is already whitelisted. I can connect to mongodb in command line proving that my ip address should be fine. How can I solve the connection error in NodeJS?

My node js version is
Node.js v23.0.0

1 Like

I’m having this same issue. Whitelisted my IP, even going as far as allowing all IPs and still, I’m getting:

MongoServerSelectionError: 80890000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1586:SSL alert number 80

I’ve referred back to my own code that worked a year ago, and even using the same module, it didn’t work. I looked through the documentation and asked the Mongo AI, but I had no luck. The AI offered deprecated code, which was unhelpful. I can’t find anywhere that has found a solution that wasn’t “whitelist your IP.”… I’ve tried several different users and nothing. The same connection string does let me connect via Mongo Compass but not through my Node JS project.

node version: v18.16.1
mongo version: 6.10.0

PS.

It works fine with a locally hosted MogoDB container, but I would prefer to be able to use an atlas…