Intermittent MongoServerSelectionError when connecting from NodeJS using Google Cloud Run + MongoDB Atlas

Hi, I am new to MongoDB Atlas too. A few days ago, I had connection problem using Python. I have managed to find a solution for that.

Just now, using MongoDB Atlas NodeJs tutorial, using the same Atlas connection string in my Python stuff. I had the below timeout error.

It turned out, my Public IP address has changed because I reset my Windows 10 internet connection. I added the new Public IP to Atlast IP whitelist and it works.

This is my case. I am new to this, I hope this might help someone…


MongoServerSelectionError: connection to 13.55.193.163:27017 closed
at Timeout._onTimeout (D:\Codes\nodejs\mongodb\node_modules\mongodb\lib\sdam\topology.js:312:38)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
reason: TopologyDescription {
type: ‘ReplicaSetNoPrimary’,
servers: Map(3) {
‘cluster0-shard-00-00 . 71o6u . mongodb . net : 27017’ => [ServerDescription],
cluster0-shard-00-01.71o6u.mongodb.net 27017’ => [ServerDescription],
cluster0-shard-00-02.71o6u.mongodb.net:27017’ => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: ‘atlas-vx7zhd-shard-0’,
logicalSessionTimeoutMinutes: undefined
}
}

2 Likes