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 on replit.

Hey, welcome to the community! This has been mentioned and the replit team is trying to fix this.
See more here : Some users are having trouble connecting to MongoDB


I see. So it’s been on going for 2 weeks now? I did experience down times, but today’s the worst because I can’t connect at all for 10 hours now.

Yeah. Could you mark my answer as the solution so people know this is solved already.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.