MongoDB Atlas was working fine at one time. Now I have not been able to connect for a time. I’ve looked at other solutions here on this forum as well as others.
I’m getting the aforementioned error using the application connection string, the MongoDB Compass app connection string as well as the MongoDB shell connection string. Here are the things that I’ve tried:
I have tried creating a new MongoDB Atlas account with a different cloud provider and region/zone. MongoDB Atlas has a connection rule in Windows Defender’s outbound rules. (Remote ports 27015- 27017). I guess this was created by MongoDB during install, so the firewall should not be an issue. Whitelisted 0.0.0.0/0 ( a security risk, but there is no valuable data here). Started using a password that doesn’t require url encoding (no special characters). Here is my software list: nodejs: v16.13.0 express: v4.18.1 mongoose: v6.5.2
I did read something about lowering the node version to fix it. If that’s the case, I’m willing to do that but what should it be lowered to?
MongoDB Compass connection string: mongodb+srv://brohjoe1:password@cluster0.4ross7o.mongodb.net/auth
Here is the error message:
App is listening at http://localhost:3001
C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\connection.js:824
const serverSelectionError = new ServerSelectionError();
^
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://docs.atlas.mongodb.com/security-whitelist/
at NativeConnection.Connection.openUri (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\connection.js:824:32)
at C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\index.js:380:10
at C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
at new Promise (<anonymous>)
at promiseOrCallback (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
at Mongoose._promiseOrCallback (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\index.js:1225:10)
at Mongoose.connect (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\index.js:379:20)
at Object.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\app.js:11:10)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(3) {
'ac-v2tectr-shard-00-01.4ross7o.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'ac-v2tectr-shard-00-01.4ross7o.mongodb.net',
port: 27017
},
address: 'ac-v2tectr-shard-00-01.4ross7o.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 1097611983,
lastWriteDate: 0,
error: MongoNetworkError: connect ETIMEDOUT 35.239.246.213:27017
at connectionFailureError (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:379:20)
at TLSSocket.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:302:22)
at Object.onceWrapper (node:events:510:26)
at TLSSocket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
[Symbol(errorLabels)]: Set(0) {}
}
},
'ac-v2tectr-shard-00-02.4ross7o.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'ac-v2tectr-shard-00-02.4ross7o.mongodb.net',
port: 27017
},
address: 'ac-v2tectr-shard-00-02.4ross7o.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 1097611977,
lastWriteDate: 0,
error: MongoNetworkError: connect ETIMEDOUT 35.232.109.33:27017
at connectionFailureError (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:379:20)
at TLSSocket.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:302:22)
at Object.onceWrapper (node:events:510:26)
at TLSSocket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
[Symbol(errorLabels)]: Set(0) {}
}
},
'ac-v2tectr-shard-00-00.4ross7o.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'ac-v2tectr-shard-00-00.4ross7o.mongodb.net',
port: 27017
},
address: 'ac-v2tectr-shard-00-00.4ross7o.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 1097612045,
lastWriteDate: 0,
error: MongoNetworkError: connect ETIMEDOUT 35.238.72.187:27017
at connectionFailureError (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:379:20)
at TLSSocket.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:302:22)
at Object.onceWrapper (node:events:510:26)
at TLSSocket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
[Symbol(errorLabels)]: Set(0) {}
}
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'atlas-bt7sor-shard-0',
logicalSessionTimeoutMinutes: undefined
},
code: undefined
}