MongoServerSelectionError: Fix for MongoDB Atlas

Share
Workaround available Node.js, Python, Java, Compass Updated November 13, 2026Based on 4 user reportsHow we research

Quick answer

MongoServerSelectionError means the driver found no reachable server within 30 seconds. On Atlas it is nearly always the IP access list, DNS/SRV lookup, a firewall on 27017, or a paused cluster.

Most likely fix: Check the IP access list

How to fix it

Try these in order — the most common fix is first.

  1. 1. Check the IP access list

    1. Go to Security > Network Access and make sure your current public IP is listed and Active
    Did this fix it?
  2. 2. Test DNS and port

    1. Run dig SRV _mongodb._tcp.<cluster-host> (nslookup -q=SRV on Windows) and confirm one record per node
    2. Run nc -zv <node-hostname> 27017
    Did this fix it?
  3. 3. Switch to the standard connection string

    1. In the Connect dialog turn off the SRV Connection String toggle
    2. Use the mongodb:// string with all three hosts
    Did this fix it?
  4. 4. Fix connection pooling

    1. If you see 'too many open connections', reuse one MongoClient per process
    2. Set maxPoolSize or scale the cluster; M0 allows 500 connections
    Did this fix it?
  5. 5. Resume the cluster

    1. On Database > Clusters resume a paused cluster and wait until it is healthy
    Did this fix it?

Symptoms

MongoServerSelectionError, ServerSelectionTimeoutError (PyMongo) or 'Server selection timed out after 30000 ms' when connecting or on the first query.

Why it happens

  • IP not in the Atlas access list
  • DNS or ISP blocking SRV lookups
  • Outbound port 27017 blocked
  • Cluster paused or deleted
  • Wrong connection string or credentials
  • Too many open connections

This guide also covers

  • mongoserverselectionerror
  • mongoserverselectionerror atlas
  • server selection timed out after 30000 ms
  • pymongo serverselectiontimeouterror atlas

Still not working?

If MongoDB Atlas keeps failing, you're not alone. See every MongoDB Atlas problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other MongoDB Atlas errors

All 10 MongoDB Atlas errors and fixes →