PS C:librarybackend> node server.js
Server is up and running on port 5000
Connection error: 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 (C:librarynode_modulesmongooselibconnection.js:896:11)
at NativeConnection.openUri (C:librarynode_modulesmongooselibconnection.js:847:11)
at async connectDB (C:librarybackendserver.js:7:9) {
reason: TopologyDescription {
type: ‘ReplicaSetNoPrimary’,
servers: Map(3) {
‘ac-ktecdkm-shard-00-02.uds5psd.mongodb.net:27017’ => [ServerDescription],
‘ac-ktecdkm-shard-00-01.uds5psd.mongodb.net:27017’ => [ServerDescription],
‘ac-ktecdkm-shard-00-00.uds5psd.mongodb.net:27017’ => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: ‘atlas-n6pjod-shard-0’,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
and I have add below code to the my Server.js
mongoose.connect(‘mongodb+srv://admin:[email protected]/library’)
.then(() => console.log(‘DB Connected’))
.catch(err => console.log(err));
could you help me to solved this error?
I’m getting this error while trying to connect to the DB using Atlas Compass and cloudMongoDb