-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDB connection error: MongooseServerSelectionError: connection timed out #9308
Comments
I have the same problem, the temporary solution is to install mongoose@5.8.13 |
yes, I didn't have a problem with earlier versions either, it was when I upgraded to the latest version of mongoose |
Can you please explain what you mean by "the configuration of mongo is in replicat set but with a single cluster"? There isn't much we can do to debug this without more information. |
I'm sorry, I meant a single node @vkarpov15 |
I have the same problem. I think "single cluster" means "a replicaset with only one node", because this is the better way to be able to use transactions on local (because a replicaset is required) |
@CarlosCondor take a look at this section on replica set hostnames: https://mongoosejs.com/docs/connections.html#replicaset-hostnames . Often, replica set connection issues are due to your machine's |
I read that section. And tried with different hostnames and it doesnt' seems to be the problem. (Now i am using Thanks for your reply |
Are you on OSX or Linux? And, if so, what is the output of running |
OSX. My hostname is |
Try using |
Doesn't work. Same error using unifiedTopology:true |
That's strange. Can you print the error's mongoose.connect('mongodb://localhost:27017/my_db_name?replicaSet=rs0', { useUnifiedTopology: true }).catch(err => console.log(err.reason)); |
hi, im also having problems with connection with localhost for mongo. it is saying: |
@oshoomhaneme please open a new issue and follow the issue template |
Hello,
when I launch the tests (unit and integration) in my project mongodb returns an error (MongoDB connection error: MongooseServerSelectionError: connection timed out).
My mongo configuration parameters are:
mongoose.connect('mongodb://localhost:27017/my_db_name?replicaSet=rs0', {}) // without options
IMPORTANT: The configuration of mongo is in replicat set but with a single cluster.
If I add the option 'use UnifiedTopology: false' the tests work correctly but it returns a warning of type: 'DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.'.
In the latest version of mongoose it indicates that using UnifiedTopology is false by default.
Why do I have to add it manually?
Framework test: mocha v5.2.0
Node version: v10.19.0
MongoDB: v4.2.3
Mongoose: v5.9.27
The text was updated successfully, but these errors were encountered: