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

258
Views
MongooseError: Operation `auths.findOne()` buffering timed out after 10000ms

MongooseError: Operation auths.findOne() buffering timed out after 10000ms at Timeout. (/home/suneel/Desktop/Project/notebook/server/models/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:148:23)

what is the problem in this code, anyone tell me?

this is my db connection file,here connect database

require("dotenv").config();
const mongoose = require("mongoose");

const connection = () => {
  mongoose
    .connect(process.env.URI,{ useNewUrlParser: true})
    .then(() => {
      console.log("DB connected");
    })
    .catch((err) => {
      console.log(err);
    });
};

module.exports = connection;

Database has been connected successfully because DB connected print in console

this is server.js

require("dotenv").config();
const express = require("express");
const app = express();
const bodyParser = require("body-parser");
PORT = process.env.PORT || 3000;

require("./db/db")();

app.use(express.json());



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

require("./routes/AuthRoutes")(app);

app.listen(PORT, function () {
  console.log(`Server is running on ${PORT}`);
});


const User = require("../models/User");
const bcrypt = require("bcryptjs");

function AuthController() {
  return {
    home(req, res) {
      res.send("Hello world");
    },
    async register(req, res) {
      const { name, email, password } = req.body;
      console.log(name, email, password);

      try {
        if (!name || !email || !password) {
          return res.send("All fields are mandatory");
        }
        const existUser = await User.findOne({ email });
        if (!existUser) {
      const salt = await bcrypt.genSalt(10);
      const Hashpassword = await bcrypt.hash(password, salt);
      const user = new User({
        name: name,
        email: email,
        password: Hashpassword,
      });
      const data = await user.save();
      if (data) {
        console.log("Register successfully");
        res.send("Register successfully");
      }
    } else {
      console.log("Already registered");
      return res.send("already registered");
    }
  } catch (error) {
    console.log("Something went wrong");
    console.log(error);
  }
},

}; }

module.exports = AuthController;

please resolve this error

about 4 years ago · Juan Pablo Isaza
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!