MongoDB Connection Refused on localhost:28000 at 19:04 CEST (Stockholm Time) — Repeated Daily

We’re seeing a recurring issue with our MongoDB Atlas cluster starting from 2025-08-06, and again on 2025-08-07, at exactly 19:04 CEST (Stockholm time) each day.

MongoDB.Driver.MongoCommandException: Command aggregate failed: Error connecting to localhost:28000 (127.0.0.1:28000) :: caused by :: onInvoke :: caused by :: Connection refused

Hi Charith,

This error means your app is trying to connect to MongoDB at localhost:28000, which is not how Atlas works. Atlas doesn’t run on localhost and doesn’t use custom ports like 28000.

This usually happens if:

  • The app has a fallback config pointing to a local MongoDB instance

  • A scheduled job or service is using a hardcoded local URI

  • You previously used a local tunnel or proxy mapped to port 28000 that’s no longer running

Atlas only supports standard remote connections over ports like 27017, and uses connection strings like:

mongodb+srv://:@cluster0.mongodb.net/?retryWrites=true&w=majority

To find your Atlas cluster’s connection string, go to the Clusters page in MongoDB Atlas. Click Connect, choose Drivers, and select your driver and version. The console will then display the connection URI, copy it and update the placeholders with your actual credentials.

I’d recommend checking any config files, environment variables, or scheduled jobs running around 19:04 CEST for lingering references to localhost.

Regards,

Marvin