Karl Aguilar
Karl Aguilar

Reputation: 1

Cant connect to mongoDB atlas even if my IP is whitelisted

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\Gigabyte\Desktop\3rdYear2ndSem\SoftEng\BatstateU-tenants\node_modules\mongoose\lib\connection.js:755:11) at NativeConnection.openUri (C:\Users\Gigabyte\Desktop\3rdYear2ndSem\SoftEng\BatstateU-tenants\node_modules\mongoose\lib\connection.js:730:11) at processTicksAndRejections (node:internal/process/task_queues:96:5)

{
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
servers: Map(3) {
      'ac-btvwsde-shard-00-00.vktogmw.mongodb.net:27017' => [ServerDescription],
      'ac-btvwsde-shard-00-01.vktogmw.mongodb.net:27017' => [ServerDescription],
      'ac-btvwsde-shard-00-02.vktogmw.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-ze47mp-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined
}

I did whitelist my public IP address provided by https://www.whatismyip.com/, however, I still get the error when I try to run my server

Upvotes: 0

Views: 1232

Answers (3)

victor maina
victor maina

Reputation: 1

I had this error even after whitelisting my IP and adding 0.0.0.0 it wasn't working and I got it fixed , The problem is with mongoose.

The latest version is having problems.

So downgrade it to 8.1.1

Upvotes: 0

Peter
Peter

Reputation: 351

Try changing the version of mongoose. for example, 7.3.0 worked for me

npm install [email protected]

Other solutions involve changing the version of node to something older or newer depending on your version of node.

Upvotes: 0

Karl Aguilar
Karl Aguilar

Reputation: 1

Finally, to solve the problem just use a VPN and whitelist the public IP address you got. This issue might be because of my ISP.

Upvotes: 0

Related Questions