I keep getting this error although I have allowed access from anywhere in the Network access section of the cluster. (Screenshot of the same is attached below)
here is the connection code
`const mongoose = require('mongoose');
const mySecret = process.env['mongoUrl']
const intialDbConnection = async () => {
try {
await mongoose.connect(mySecret, {
useNewUrlParser: true,
useUnifiedTopology: true
})
console.log("db connected")
}
catch (error) {
console.error(error);
}
}
module.exports = { intialDbConnection }`
**
And the entire code is here https://replit.com/@KumaraswamyA/store-cipher-backend-1
**(store-cipher-backend-1 - Replit)
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 (/home/runner/store-cipher-backend-1/node_modules/mongoose/lib/connection.js:824:32)
at /home/runner/store-cipher-backend-1/node_modules/mongoose/lib/index.js:380:10
at /home/runner/store-cipher-backend-1/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
at new Promise (<anonymous>)
at promiseOrCallback (/home/runner/store-cipher-backend-1/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (/home/runner/store-cipher-backend-1/node_modules/mongoose/lib/index.js:1225:10)
at Mongoose.connect (/home/runner/store-cipher-backend-1/node_modules/mongoose/lib/index.js:379:20)
at intialDbConnection (/home/runner/store-cipher-backend-1/db/db.connect.js:5:20)
at Object.<anonymous> (/home/runner/store-cipher-backend-1/index.js:15:1) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(3) {
'cluster0-shard-00-00.fkvic.mongodb.net:27017' => [ServerDescription],
'cluster0-shard-00-01.fkvic.mongodb.net:27017' => [ServerDescription],
'cluster0-shard-00-02.fkvic.mongodb.net:27017' => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'atlas-on2j4f-shard-0',
logicalSessionTimeoutMinutes: undefined
},
code: undefined
}