Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2.7K
Views
Operation `users.insertOne()` buffering timed out after 10000ms in, Node.js, MongooseError

I am busy creating a project which allows the user to enter "Email" & "Password" to register to the site,

When I try to enter a user using the "Email" & "Password" to enter this site, I get the following error:

MongooseError: Operation users.insertOne() buffering timed out after 10000ms

Unhandled rejection MongooseError: Operation users.findOne() buffering timed out after 10000ms

I have tried all the proposed solutions I found here which have a similar problem, delete the node_modules folder and reinstall mongoose.

Please see my code below, thanks!

const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");
const mongoose = require("mongoose");

const app = express();

app.use(express.static("public"));
app.set('view engine', 'ejs');

app.use( bodyParser.urlencoded ({extended: true}));

mongoose.connect = ("mongodb://localhost:27017/userDB", {useNewUrlParser: true, useUnifiedTopology: true});

const userSchema = {
  email: String,
  password: String
};

const User = new mongoose.model("User", userSchema);

app.get("/", function(req, res){
res.render("home")
});

app.get("/login", function(req, res){
res.render("login")
});

app.get("/register", function(req, res){
res.render("register")
});

app.post("/register", function(req, res){
const newUser = new User({
  email: req.body.username,
  password: req.body.password
  });
  newUser.save(function(err){
    if (err) {
      console.log(err);
    } else {
      res.render("secrets");
   }
 });
});

Can anyone help me out?

Atom images - Project SecretsCode

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

try adding one more line under mongoose.connect curly braces:-

mongoose.connect("monogodb://localhost....,{useNewUrlParser:true,
    useUnifiedTopology:true,
    useCreateIndex:true}).then(()=>{
console.log(`successfully connected`);
}).catch((e)=>{
console.log(`not connected`);
})

you can check the error in console if not connected by replacing "not connected" with 'e'

over 4 years ago · Santiago Trujillo Report

0

I was having the same issue, Make sure that your mongoDB database username and password is alphanumeric with no special symbols. And dont add this:

    useUnifiedTopology:true,
    useCreateIndex:true}) ```
simply write this:
```mongoose.connect(process.env.MONGO_URL,).then(()=>{
    console.log(`successfully connected`);
    }).catch((e)=>{
    console.log(`not connected`);
    }); ```
over 4 years ago · Santiago Trujillo Report

0

For a reason my IP address changed, so I had to update it inside Mongo DB - NetworkAccess - Edit - Use the new IP address, maybe you'll see a button to update with current Ip or something like that, click it

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!