MongoDB atlas stopped working on replit (Python, pymongo)

Replit staff member ^^. So that may be the fix


@not-ethan that’s not the fix :slight_smile: we’re working on a fix for the Mongo not connecting issue


Bardia, it worked for 48 hours and broke again this morning. What’s going on! :smiling_face_with_tear:

When can we expect a fix?

We have our engineering team working on it right now. Hopefully by the end of the week, maybe next week. Sorry for the disruption to our services!


Same here, it didn’t work, then worked for a while, and now doesn’t work.

I have a fix that works for me. I imported dns and my problems were resolved

import os
import dns
os.system("python -m pip install \"pymongo[srv]\"")
import pymongo
1 Like

Update: We are still digging into this issue


I’m also having Server selection error using Node.js. I think is something related to name resolution in the container.

I don’t do mongo, but see if this code works around the issue. It’s meant to switch the IP when the error happens

const { MongoClient, MongooseServerSelectionError } = require("mongodb");
// minimal webserver if you don't already serve a website
  .createServer((_, r) => r.end())
try {
  // whatever code you use to connect, like
  await new MongoClient(yourConnectionURI).connect();
} catch (err) {
  if (err instanceof MongooseServerSelectionError) {
    require("https").get(`https://${process.env.REPL_ID}`, () =>

This exact error randomly showed up on my repl today after no changes and having worked flawlessly for months.

Is there a solution for this? Python with PyMongo?


Yep started again for me too yesterday

1 Like

again, no experience with mongo but

import pymongo, os, multiprocessing
from pymongo import errors
from urllib import request
from http import server

# minimal server for if your code isn't already serving a website before you connect to mongodb
class Server(server.BaseHTTPRequestHandler):
    # Do this to override the log_request function to prevent spammy logging output
    def log_request(_, __):

    def do_HEAD(self):

    do_GET = do_HEAD

    target=server.ThreadingHTTPServer(("", 80), Server).serve_forever
    # connect to mongo here, e.g.
    client = pymongo.MongoClient(
except errors.ServerSelectionTimeoutError:
    os.kill(1, 1)
1 Like

I’m now getting mongodb errors again (node.js), with Internal Server Error and Unknown system error -122. Looks like this issue wasn’t fully fixed and a timeframe on when this could be resolved would be great.

1 Like

Is there any update to this? Is it working again for anyone?

1 Like

No, it’s still a common error.

1 Like

This is really troublesome. It’s been 15 hours and I still can’t connect to MongoDB with replit.

1 Like

Yeah, very annoying.

1 Like

Yep really hurts my usability of Replit

1 Like

I don’t think it’s an issue on Replit’s side. I don’t know for certain, but my theory is that one of Replit’s IPs is blacklisted from Mongo as it’s only an issue sometimes and kill 1 sometimes helps.

1 Like

I apologize for our sparse updates! We are still coordinating with our upstream providers to find the cause. I have prompted the Replit team for an update and will revert here once I get a reply.