MongoDB connection error: MongoNetworkError: when hosted on cyclic
Asked Answered
G

2

6

I have a NodeJs API hosted on cyclic. Everything worked fine earlier but I exhausted my free tier API request and my app was suspended, then had to upgrade. Since then I have been having this error

 MongoDB connection error: MongoNetworkError: 805C21D67D7F0000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:1586:SSL alert number 80

    at connectionFailureError (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:367:20)
    at TLSSocket.<anonymous> (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:290:22)
    at Object.onceWrapper (node:events:629:26)
    at TLSSocket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  cause: [Error: 805C21D67D7F0000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:1586:SSL alert number 80
  ] {
    library: 'SSL routines',
    reason: 'tlsv1 alert internal error',
    code: 'ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR'
  },
  connectionGeneration: 2,
  [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
}

I have tried everything, I thought my mongo free tier was exhausted. I upgraded that, to no avail. I updated my mongoose package, I have tried searching online but couldn't find any thing. This how I connect to my database in the index.js //Connect to the database before listening

connectDB().then(() => {
  app.listen(PORT, () => {
    console.log(`App listening on port ${PORT}`);
  });
});

And this my connectDB function

const mongoose = require("mongoose");

const connectDB = async () => {
  try {
    await mongoose.connect(process.env.MONGO_URL, {
      useNewUrlParser: true,
      useUnifiedTopology: true,
    });
    console.log("MongoDB connected");
  } catch (error) {
    console.error("MongoDB connection error:", error);
  }
};

module.exports = connectDB;

What exactly could be causing that error and how do I rectify is

Gavin answered 26/8, 2023 at 1:52 Comment(1)
I'm also getting the same error, Have you fixed it?Cormier
C
13

The ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR error (above) can be caused by not whitelisting your IP in Mongo Atlas. Make sure you're not blocked by the Network Access settings! It's a little misleading since it's an "ssl error", but it's actually just telling you that the SSL handshake could not complete (because you're IP is not whitelisted).

So that's at least one possible solution to this error.

Choleric answered 14/9, 2023 at 22:57 Comment(2)
I also found discrepancies between using a free shared cluster, and a dedicated cluster - since I had opened up the network to all connections and still faced this issue until swapping the uri to a dedicated cluster uriColwin
That's interesting, thanks for sharing that nuance!Choleric
J
0

i got same error go to network access on left side and configure your ip address or allow from anywhere

Jelle answered 17/6 at 7:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.