MongooseError: Operaton people.insertOne() buffering timed out after 10000ms.
I have follow each explanation from the articles given, and have read every related thread to fix this problem. But the solutions ain’t work for me.
I’ve tried surrounding my MONGO_URI in the .env file with single quotation marks, and vice versa, also defining DB_NAME in the .env, use useFindAndModify, useCreateIndex, useUnifiedTopology and set it to true, install mongoDB, create DB and Collection in Atlas.
Answer#Q1:
I did not receive any connection log in my terminal besides of this error: MongooseError: Operaton people.insertOne() buffering timed out after 10000ms. After HTTP GET request log.
Here is the detailed error information:
/*
MongooseError: Operation `people.insertOne()` buffering timed out after 10000ms
at Timeout.<anonymous> (P:\course\FreeCodeCamp - Back End Development and APIs\boilerplate mongomongoose\boilerplate-mongomongoose\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
queryTxt ETIMEOUT <clustername>.mongodb.net
*/
Answer#Q2:
I have tried to put my DB name to the connection string (<cluster>.mongodb.net/fcc-learning-mongo-mongoose?retryWrites=true&w=majority).
I’ve also tried to use the default connection string which include appName=Cluster0 param, but it still throw me the same error
My conclusion:
I think the issues lies with my MongoDB Atlas config. I’am not able to attach the image, so I will describe it instead:
Network Access: 0.0.0.0/0 | Status: Active
Database Access: 3 user listed, two of them as readWriteAnyDatabase and the other as atlasAdmin
Yes it looks like mongoose failed to connect to my MongoDB Atlas. I’m using Visual Studio Code, is it necessary to install additional extensions or lib?
Yeah it catch a throw, and only display this log: queryTxt ETIMEOUT <clustername>.mongodb.net
I’ve remove the dbName from the connection params and define it explicitly in the MONGO_URI, you can take a look at my source code from the previous link.
In my .env file, there’s about 8 variables. I tried to connecting the mongoose to my MongoDB Atlas with each of those variables. But it still giving me the same error.
MONGO_URI, contain the default connection string given by the MongoDB Atlas, and adds the name of the database I have previously created in Atlas.
MONGO_URI_WITH_QUOTATION, same as before but the string wrapped in quotes.
MONGO_URI_WITH_COLLECTION, adds the name of the collection from the database that I created previously.
MONGO_URI_WITH_COLLECTION_QUOT, same with point number 3, but the string wrapped in quotes.
MONGO_URI_NEW_DB, same with point number 1, but adds database name that haven’t created yet in Atlas (not exists).
MONGO_URI_NEW_DB_QUOT, same with point number 5 and wrapped the string with quotes, etc.
Because Replit does not support .env files and you have to use the secrets option. I might suggest you try running it on Gitpod or Replit to see if it is an issue with your local setup (network, etc.).
If I search for the error message, I mostly get issues with DNS or other network related stuff.
Yes by now this project is running on my local computer. I will try to use both of your suggestions, if I’m stuck on running it locally.
Sadly, it didn’t work in my case either, by changing the default DNS with Google DNS both in my web browser and in my internet connection (IPV4 and IPV6).
Sorry being late in replying your comment, I’m giving up on running it locally, and trying to run it remotely on Gitpod as your suggestion, and yeah its works fine even though my MongoDB Atlas account is signed out.
After checking my MongoDB Atlas, it shows me a database called test with people collection inside of it.
Also, in my Gitpod terminal it show me this log:
(node:2160) [DEP0170] DeprecationWarning: The URL mongodb://<username>:<password>@<cluster>.mongodb.net:27017,<cluster>.mongodb.net:27017,<cluster>.mongodb.net:27017/?authSource=admin&replicaSet=atlas<cluster>&retryWrites=true&w=majority&appName=Cluster0&ssl=true is invalid. Future versions of Node.js will throw an error.
(Use node --trace-deprecation ... to show where the warning was created)
Conclusion:
Perhaps the cause of the problem comes from my personal computer or my code editor (Visual Studio Code) or perhaps both.
Finally! I got the solution on how to solve this issue.
Simple things you should do is just select the older version of Node.js driver in your MongoDB Atlas and choose ver. 2.2.12 or later.
I’m not exactly sure how this is works, even though I’m using the latest version of npm and node.js on my local computer.
Additional Step#1:
If this does not work in your case, try changing your Network Connection’s IPv4 DNS to Google’s DNS (additional step).
Preferred DNS server: 8.8.8.8
Alternate DNS server: 8.8.4.4
Additional Step#2:
I’m not sure this thing will work or not, If you still facing with the same error and you’re using Visual Studio Code, try to forward your port , e.g 3000, 5000 and set the visibility to Public.
Open the forwarded address in your browser, you can use that address as your project link instead of using your localhost address.