MongoDB atlas stopped working on replit (Python, pymongo)

Same problem in hackerplan. But works perfectly in free plan.

Then, What is the benefit of Pro member?!

Fix it please.
Link to my repl: https://replit.com/@NafisAfzal2017/Mongo-Test

1 Like

i have the same problem, is this bug is going to be fixed or what? if yes, please fix it ASAP, im begging…

FIXED!

My repls are running as okay! :")

Thanks replit team. <3

2 Likes

Great to hear @NafisAfzal2017!

We’re working on a fix!

1 Like

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

2 Likes

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

4 Likes

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!

3 Likes

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

2 Likes

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
require("http")
  .createServer((_, r) => r.end())
  .listen();
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}.id.repl.co`, () =>
      process.kill(1)
    );
  }
}

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?

Thanks!

Yep started again for me too yesterday

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(_, __):
        pass

    def do_HEAD(self):
        self.send_response(204)
        self.end_headers()

    do_GET = do_HEAD


multiprocessing.Process(
    target=server.ThreadingHTTPServer(("", 80), Server).serve_forever
).start()
try:
    # connect to mongo here, e.g.
    client = pymongo.MongoClient(
        f"mongodb+srv://admin:{os.environ['db-password']}@cluster0.1shpg.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
    )
except errors.ServerSelectionTimeoutError:
    request.urlopen(f"https://{os.environ['REPL_ID']}.id.repl.co")
    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