MongoDB MCP: ServerSelectionTimeoutError against Atlas (IP not on the access list)
Fixes the MongoDB MCP server timing out against MongoDB Atlas with ServerSelectionTimeoutError. The usual cause is the Atlas IP access list not including the machine running the MCP client. The fix is adding the current IP in the Atlas dashboard. Use when local MongoDB works but Atlas times out; not for auth errors.
TL;DR: Timeouts against Atlas almost always mean your IP is not on the Atlas access list. Atlas drops the packets silently, so the driver just times out. Go to Network Access in the Atlas dashboard and add your current IP.
MongoServerSelectionError: connection timed outFix it
- In the Atlas dashboard, open Network Access for your project and check the IP access list.
- Add your current public IP. Find it with:
curl -s https://api.ipify.org Add it as a single IP entry. For a quick test you can use the all-interfaces address/0 (allow from anywhere), but replace it with your real IP afterward.
- Wait a minute for the change to propagate, then restart the MCP client or retry the tool call.
Expected: the server connects within seconds and tools respond.
When to use this
- Local MongoDB (
mongodb://YOUR_HOST:27017) works, but the Atlasmongodb+srv://URL times out. - The timeout happens consistently, not intermittently.
When NOT to use this
- The error is
bad authorauthentication failed. Your IP is fine; the credentials are wrong. - The error mentions DNS or SRV lookup failures. That is a DNS problem, not the access list.
Compatibility
- mongodb-mcp-server against MongoDB Atlas (any tier).
- Any MongoDB driver, the failure mode is identical.
Why it happens
Atlas defaults to deny-all networking. Unlike a wrong password, which gets an explicit rejection, a non-allowlisted IP gets its packets dropped with no response. The driver's server-selection loop waits for a response that never comes and eventually reports a timeout, which misleads people into debugging DNS or drivers.
Edge cases
- Home IPs change. If it worked yesterday and times out today, your ISP rotated your IP. Re-add it.
- VPNs change your egress IP. Add the VPN exit IP, or disconnect the VPN for testing.
the all-interfaces address/0is fine for a five-minute test, not for production. Narrow it as soon as it works.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.