Replit, I just can't. MongoDB stopped working again (MongoServerSelectionError: ReplicaSetNoPrimary)

Problem description:
I’m receiving error when connecting to my MongoDB in replit. It started to happen a few minutes ago. I posted the same exact issue here: MongoDB suddenly stopped working (MongoServerSelectionError: ReplicaSetNoPrimary). The error on that previous thread got fixed after 24 hours.

Where’s the fix for this bug?? Should I wait 24 hours again and let time fix this again?? Is this inevitable? I can connect just fine with Visual Studio local client. This error seems ongoing for a month now. Even the guys from MongoDB said it’s been an ongoing issue since November 2022 and replit team can’t seem to make any changes about it. I’m wasting precious time.

Expected behavior:
It should connect just fine.

Actual behavior:
It shows these errors,

MongoServerSelectionError: getaddrinfo ENOTFOUND ac-8q8dm3y-shard-00-00.5ldtt3z.mongodb.net
at Timeout._onTimeout (/home/runner/Bojji/node_modules/mongodb/lib/sdam/topology.js:285: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) {}
}

Steps to reproduce:
Establish connection to MongoDB
Run code.

Browser/OS/Device:
Windows 11

I just subscribed to Hackers Plan. There’s still an error. OMG

Hey there! This has already been noted by the replit team. Some users are having trouble connecting to MongoDB

The same thing keeps happening to me while paying for always awake. It doesn’t happen too often but every couple of days I see it happen again.

yeah, that’s what I mean.

Still down. This is really frustrating

The team have know about this for more than half a month. This is a complex issue and they have been working hard on a fix. @IroncladDev any updates?

Unfortunately I don’t have much context on this. Handing it over to @ShaneAtReplit

This has been an issue for a while, really frustrating (I have a lot of projects relying on MONGO)

No updates yet. I’ve been making sure we’re working on a fix

2 Likes

These MonogDB connection issues are still happening on a regular basis with my Repls. Very frustrating, especially because I’m paying for Always On and I have no control over the outages.

This is no longer the case. We have been able to reproduce and no longer need users to perform these steps.

1 Like

after dig

; <<>> DiG 9.18.8 <<>> @1.1.1.3 ac-vp43tln-shard-00-00.s5hnrg0.mongodb.net
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 3065
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;ac-vp43tln-shard-00-00.s5hnrg0.mongodb.net. IN A

;; Query time: 12 msec
;; SERVER: 1.1.1.3#53(1.1.1.3) (UDP)
;; WHEN: Sun Apr 09 12:13:24 UTC 2023
;; MSG SIZE  rcvd: 71

Please see below the link to my repl. The Repl used to connect fine for some time but for more than a day now there is the same error as described in this post and although it manages to connect for a small period of time it drops off soon after.

Welcome to Replit Ask! I hope mongodb starts working eventually.

1 Like


This is my error, and use this to connect to mongo

Blockquote
async function connectDB() {
mongoose.set(‘strictQuery’, false);
await mongoose.connect(MONGO).then(() => console.log(“Database Connected! Hopefully ig”.red)).catch((e) => console.log(Database Connection Failed: ${e} .red))
}
connectDB();

1 Like

Try whitelisting 0.0.0.0 in your db configuration.

2 Likes

aldready done… also this is happening on all of my bots and the network access IS allowed from anywhere

Same in my case. Several repls behaving the same. My network access in MongoDB is set to public allowing connection from anywhere.

I’ve got the same issue here, even though my MongoDB server allows network access from any IP.