MongoDB drivers do not connect to one fixed server; they discover the deployment's topology and select a node matching the operation's requirements (a primary for writes, for instance). Server selection timed out after 30000 ms (in some drivers worded ServerSelectionError) means that discovery never produced a usable node within the timeout: every candidate was unreachable, rejected, or unsuitable. The message deliberately bundles several causes, and the driver's wrapped inner errors and the topology description it logs name which one, so the diagnosis is in the details the application may be swallowing.
+srv string whose DNS SRV lookup fails or is filtered. Test the same string with mongosh from the same machine and network as the application; it prints precise DNS and connection errors the driver buries.0.0.0.0/0 “to make it work” removes the control entirely and should only ever be a momentary diagnostic.serverSelectionTimeoutMS only for genuinely slow starts (cold containers, distant regions). Raising it on an unreachable cluster changes nothing but how long each request waits before failing; the default 30 seconds is already generous.Why did it start after we deployed to a new environment? The application's network identity changed: new egress IPs meet an Atlas allowlist written for the old ones. It is the first thing to check after any hosting move, ahead of the connection string, which usually travels unchanged.
mongosh connects but the application times out, why? They are not using the same inputs: compare the exact connection string, the driver version's default options (some older drivers mishandle SRV or TLS defaults), and whether the application runs in a different network namespace (container, VPC) than the shell where mongosh succeeded.
Can I lower the timeout so failures surface faster? Yes, serverSelectionTimeoutMS is configurable and lowering it in user-facing paths is reasonable once connectivity is proven healthy. It changes failure latency, not failure likelihood.