Unable to connect local env to Atlas: SSL/TSL Connection Issue

Hi,

I am unable to connect local env to Atlas. I get the ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR error.

I have:

  • whitelisted my IP (tried public and private IP)
  • Used 0.0.0.0 IP
  • Terminated and restarted the cluster
  • built new account
  • shared hotspot instead of wifi

I still can’t connect my local environment to MongoDB.
I use MacOS, I am developing with node.JS and leverages Chrome. There is no Firewall in place.

Full details of the error:

[Symbol(errorLabels)]: Set(1) { 'ResetPool' },
    [cause]: [Error: 00C6701901000000: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
    ] {
      library: 'SSL routines',
      reason: 'tlsv1 alert internal error',
      code: 'ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR'
    }
  }
}``
1 Like

Are you using a current version of TLS to connect?
Is your Node version up to date?

See:

Hi Jack, thank you for your message.

  • I have Node v18.16.0.
  • I am unfamiliar with TLS versioning. I am building my project on localhost. I ran node -p process.versions.tls in my project and it came back as “undefined”.

Here is the full error output for viz:

MongoServerSelectionError: 00560D1701000000: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

    at Topology.selectServer (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/sdam/topology.js:320:38)
    at async Topology._connect (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/sdam/topology.js:204:28)
    at async Topology.connect (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/sdam/topology.js:156:13)
    at async topologyConnect (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/mongo_client.js:233:17)
    at async MongoClient._connect (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/mongo_client.js:246:13)
    at async MongoClient.connect (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/mongo_client.js:171:13)
    at async run (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/mongo.js:54:3) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'cluster0-shard-00-01.95yeh.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-00.95yeh.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-02.95yeh.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-7bpf9y-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {},
  [cause]: MongoNetworkError: 00560D1701000000: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
  
      at TLSSocket.<anonymous> (/Users/baptistefernandez/Desktop/01-refresher-starting code/refresher/node_modules/mongodb/lib/cmap/connect.js:285:44)
      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) {
    [Symbol(errorLabels)]: Set(1) { 'ResetPool' },
    [cause]: [Error: 00560D1701000000: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
    ] {
      library: 'SSL routines',
      reason: 'tlsv1 alert internal error',
      code: 'ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR'
    }
  }
}

type or paste code here

What is your operating system and its version, please?

Hi Jack, thanks for your patience.

My operating system is: macOS Monterey with Version 12.7.6

My Macbook Pro is a little old (13-inch, 2016, Two Thunderbolt 3 ports). This means that I am unable to update past the Monterey version disclosed above.

If my old hardware is the issue, is there a way for me to bypass this using Docker or else? I would really appreciate any solution. For context, this is my first time working with MongoDB so any guidance would be great.

How did you install?

I don’t recall actually.

What is the command you are using to do the connection?

It is made inside my app.js file:

const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');

const placesRoutes = require('./routes/places-routes');
const userRoutes = require('./routes/user-routes');
const HttpError = require('./models/http-error');

const app = express(); 

app.use(bodyParser.json());

app.use('/api/places', placesRoutes); 
app.use('/api/users', userRoutes);

mongoose.connect('mongodb+srv://bap:<hidingmypassword>@cluster0.l23b4.mongodb.net/places?retryWrites=true&w=majority&appName=Cluster0')
.then(() => {
    app.listen(5000);
})
.catch(err => {
    console.log('error connecting to MongoDB:', err);
});

Can you connect to Atlas from MongoDB Compass?

I am able to connect to Atlas from MongoDB Compass.

What happens if you change your mongoose connect URI to:

'mongodb+srv://bap:<hidingmypassword>@cluster0.l23b4.mongodb.net/places?tls=true&retryWrites=true&w=majority&appName=Cluster0')

I get this error:

[nodemon] starting `node app.js`
Error connecting to MongoDB: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/
    at _handleConnectionErrors (/Users/baptistefernandez/Desktop/Backend/node_modules/mongoose/lib/connection.js:1110:11)
    at NativeConnection.openUri (/Users/baptistefernandez/Desktop/Backend/node_modules/mongoose/lib/connection.js:1041:11) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'cluster0-shard-00-00.l23b4.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-01.l23b4.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-02.l23b4.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-s2vrlb-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined
}
[nodemon] clean exit - waiting for changes before restart

Hi, I’m coming back to you on this. Thanks

the problem is typically related to either network connectivity, i.e. you don’t have a firewall rule enabling you to connect to the cluster from your local IP address. and/or authentication credentials, i.e. you don’t have your user id and password correct.

To troubleshoot, try connecting from mongosh / command line… you’ll get some more information… please share that.

Let us know how you make out.

The weirdness, @Michael_Lynn , is that they say they’re able to connect via Atlas.