MongoDB suddenly stopped working (MongoServerSelectionError, ReplicaSetNoPrimary)

For some reason, I’m receiving this error when connecting to my MongoDB in replit. It was all working fine like 8 hours ago, and been connecting with it for 2 weeks now.


MongoServerSelectionError: getaddrinfo ENOTFOUND
    at Timeout._onTimeout (/home/runner/Bojji/node_modules/mongodb/lib/sdam/topology.js:292:38)
    at listOnTimeout (node:internal/timers:557:17) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'primary' => [ServerDescription],
      'secondary' => [ServerDescription],
      'secondary' => [ServerDescription]
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-q5c7wq-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}

Here’s my connection string:


Here are the things I tried but to no avail:

  • Used Google DNS.
  • Added IP Whitelist
  • Added my IP in whitelist
  • Disabled Windows Defender
  • Updated my Mongo User password.
  • Restarted my router 3x.
  • Used mobile data.
  • Allow outbound port 27015-27017 in firewall

Here are other information:
Mongodb Cluster version: 5.0.14
Mongodb Cluster Tier: M0 Sandbox (General)
Mongodb type: Replica Set - 3 nodes
Mongodb Package version: 4.13.0
Windows OS: Windows 11

More information:
I can connect and query just fine in MongoDB Compass. It happens in replit.

It’s been 12 hours. It still isn’t working.

In addition:

What’s happening?

Hi @Philip_Kristoffer_Tosing,

I’m not too familiar with replit but I have found the following on our forums regarding replit connectivity to Atlas with “no changes made” as well.

It could possibly be related to MongoDB atlas stopped working on replit (Python, pymongo) - #15 by thedankboi - Bug Reports - Replit Ask

The only reason I speculate this is because you’re able to connect with Compass which shows to me there isn’t any issues with the cluster. In addition to that, I have not found any issues reported on recently.

Might be worth double checking with replit as well in this case as your troubleshooting looks okay to me at this stage. If you want, you could also contact the atlas in-app chat support team to check if there are any issues with your cluster although since you have connected with Compass it may not be the case. Good to may be double check though.