Hi, I’m having problems with connecting to MongoDB Atlas from a Google Cloud Run instance. I’m intermittently (a few times per day) getting a MongoServerSelectionError when my server is initializing and trying to connect. This is my current setup:
Using M10 tier cluster on MongoDB 4.4.
Connecting using NodeJS driver version 3.6.0.
useUnifiedTopology set to true.
Whitelisted all IP addresses in MongoDB atlas for the cluster.
I’m not seeing any alerts in MongoDB atlas. Please note that this is an intermittent issue. Sometimes it connects sometimes it doesn’t. Because my app currently has very low traffic there is never more than one instance running so the 30-second timeout + time to restart of the container makes this problem critical.
Has this issue been resolved for you? I’m having the same issue, of intermittent connectivity due to a timeout, but mine is happening from a DigitalOcean droplet. I’ve tried almost everything, except use Mongoose.
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…
The problem happens intermittently, it does not follow a pattern, it has already happened twice in a day, but it has also been about a month without happening. Here is the error received from the application:
connection timed out MongoServerSelectionError: connection timed out
at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/topology.js:438:30)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
I tried allow conection from 0.0.0.0/0 but dont work