I keep getting error when i try connecting node to mongodb

App is listening on port 5001

/Users/olumayokunogunfowora/Desktop/complete-node-bootcamp-master/4-natours/starter/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:367
            return new error_1.MongoNetworkError(err);
                   ^

MongoNetworkError: 80203CF601000000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1586:SSL alert number 80

    at connectionFailureError (/Users/olumayokunogunfowora/Desktop/complete-node-bootcamp-master/4-natours/starter/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:367:20)
    at TLSSocket.<anonymous> (/Users/olumayokunogunfowora/Desktop/complete-node-bootcamp-master/4-natours/starter/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:290:22)
    at Object.onceWrapper (node:events:628:26)
    at TLSSocket.emit (node:events:513: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: 80203CF601000000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/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: 1,
  [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
}

Node.js v18.16.1
[nodemon] app crashed - waiting for file changes before starting...
1 Like

Good afternoon, welcome!

You can pass information about your connection, how you are creating, if you are using Atlas or your own servers. This will help people understand the problem.

1 Like

One possible cause to this for Mongo Atlas in particular, is if your IP is not whitelisted. In that case, the SSL handshake fails. The error is a little misleading, but I was getting an “ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR” until I whitelisted my IP address.

9 Likes

Yeah Thanks,It really helped me

2 Likes

Hey!
did you figure out the olutio i am getting the same erro.

Here

“One possible cause to this for Mongo Atlas in particular, is if your IP is not whitelisted. In that case, the SSL handshake fails. The error is a little misleading, but I was getting an “ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR” until I whitelisted my IP address.”

3 Likes

Can you please guide me how to whitelist ip

Instructions are in the documentation:

When creating a deployment it should automatically add your current IP or at least give you the option.

1 Like

In the security section you go to “Network Access” → “Add IP Address” then select any IP address

2 Likes

it helps me too so thank you for this post so other developer can take advantage of

1 Like

if you are using Any VPN or any shield like Macfree etc . off it from your settings and once try again. For me it worked.

Thank you for sharing, this helped me

after your mongo url add “databaseName?retryWrites=true&w=majority” this help in clearing the error::

2024-08-14T10:32:43.997Z26634a0dMongoDB connection error: MongoServerSelectionError: 809C140952780000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1590:SSL alert number 80

2024-08-14T10:32:43.999Z26634a0d arbiters: [],

2024-08-14T10:32:43.999Z26634a0d code: undefined
1 Like

This also woks for me.
Thanks

Thanks for this, really helped me out now

i already whitelisted my ip but still error but if i set ip to 0.0.0.0/0 it works but i dont want to set it to 0.0.0.0/0 i want to set it to my own ip address. do you have any solution?

I added the IP address to the whitelist but it didn’t work. Even using 0.0.0.0

It happened to me when I upgraded mongo node.js driver from 6.3.0 to 6.9.0.
Downgrading back to 6.3.0 and the issue is gone.

1 Like

downgrading to 6.3 worked for me too

1 Like

update: I updated my node version the latest LTS (v20.17.0) and everything is working fine with the new driver