{ useUnifiedTopology: true } leads to MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms
Problem
*Do you want to request a feature or report a bug? A bug. What is the current behavior? After updating to Mongoose 5.7.1, the following warning appeared: [code block] I added `useUnifiedTopology: true` to my mongoose config object as suggested by the message, even though I'm not using MongoDB replica set or sharded cluster. Here is how I configure and connect using mongoose: [code block] and here is where I used this `mongo.options` object: [code block] The warning is gone but the issue is that mongoose is now no longer able to connect: [code block] Here is how I run MongoDB using docker during development: [code block] If the current behavior is a bug, please provide the steps to reproduce. See above What is the expected behavior? Mongoose should remove the deprecation warning and run fine when using `useUnifiedTopology: true` as mongoose suggests. What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.* Node: v10.16.2 Mongoose: 5.7.1 (latest) MongoDB: db version v4.2.0 Related issues: - https://github.com/Automattic/mongoose/issues/8156 - https://github.com/Automattic/mongoose/issues/8169
Error Output
error: MongoTimeoutError: Server selection timed out after 30000 ms
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: { useUnifiedTopology: true } leads to MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms
I am also getting both errors (Server selection timed out after 30000 ms and MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11) when using useUnifiedTopology so this is happening to everyone that uses this option I guess.
Trust Score
3 verifications
- 1
I am also getting both errors (Server selection timed out after 30000 ms and Max
I am also getting both errors (Server selection timed out after 30000 ms and MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11) when using useUnifiedTopology so this is happening to everyone that uses this option I guess.
Validation
Resolved in Automattic/mongoose GitHub issue #8180. Community reactions: 2 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep