I'm encountering an issue while trying to connect to a MongoDB Atlas cluster from my Node.js application using Mongoose. Whenever I attempt to connect, I receive the following error message:
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 (C:\Users\user\Desktop\book store mern project\backend\node_modules\mongoose\lib\connection.js:875:11)at NativeConnection.openUri (C:\Users\user\Desktop\book store mern project\backend\node_modules\mongoose\lib\connection.js:826:11)at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
reason: TopologyDescription {type: 'ReplicaSetNoPrimary',servers: Map(3) {'ac-zatxspx-shard-00-00.fm6scd3.mongodb.net:27017' => [ServerDescription],
'ac-zatxspx-shard-00-01.fm6scd3.mongodb.net:27017' => [ServerDescription],
'ac-zatxspx-shard-00-02.fm6scd3.mongodb.net:27017' => [ServerDescription]
},stale: false,compatible: true,heartbeatFrequencyMS: 10000,localThresholdMS: 15,setName: 'atlas-ti4xbm-shard-0',maxElectionId: null,maxSetVersion: null,commonWireVersion: 0,logicalSessionTimeoutMinutes: null},code: undefined.
I've already ensured that my current IP address is whitelisted in the MongoDB Atlas cluster settings, but I'm still encountering this issue. I've been trying to troubleshoot for some time now, but haven't had any success.
Any insights or suggestions on how to resolve this issue would be greatly appreciated. Thank you!
I've already ensured that my current IP address is whitelisted in the MongoDB Atlas cluster settings. Additionally, I've verified the MongoDB connection string in my application and confirmed that it's correctly configured with the appropriate username, password, and database name.
Despite these efforts, I'm still encountering the connection error. I've spent some time troubleshooting but haven't had any success.
I'm expecting to be able to establish a connection to the MongoDB Atlas cluster successfully without encountering the error mentioned above.