title: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
body: <p>This is my connection file</p>
  <pre><code>
  const connectDB = async () =&gt;{
          const conn = await new mongoose(&quot;mongodb+srv://nikunj:gadia7420@cluster0.94xph.mongodb.net/myFirstDatabase?retryWrites=true&amp;w=majority&quot;,
          {
              usenewurlparser:true,
              usecreateindex:true,
              usefindmodify:true,
              useunifiedtropology:true,
              urlencoded:true
          })
  }
  module.exports = connectDB;
  </code></pre>
  <p>this is my models file</p>
  <pre><code>
  const userSchema = new mongoose.Schema({
      username:{
          type:String,
          required:true
      },
      avatar:{
          type:String,
      },
      email:{
          type:String,
          required:true
      },
      password:{
        type  : String,
       required:true
      }
  });
  module.exports = mongoose.model('user',userSchema);
  </code></pre>
  <p>this file will insert or take information from database for registeration</p>
  <pre><code>const express = require('express');
  const router = express.Router();
  const User = require('../models/user');
  const bcrypt= require('bcrypt');
  
  router.post('/register',async(req,res,next)=&gt;{
      const  {username,email,password}=req.body;
      try{
          let user_exist = await User.findOne({email:email});
          if(user_exist){
              success=&quot;false&quot;;
              msg=&quot;user already exist&quot;;
          } else {
              //importing data to models
              let user = new User();
              user.username = username;
              user.email = email ;
              const salt = await bcrypt.genSalt(10);
              user.password =  await bcrypt.hash(password,salt),
              user.avatar =  &quot;https://gravatar.com/avatar/?s=200&amp;d=retro&quot;
              await user.save();
              res.json({
                  sucess:true,
                  user:user,
                  msg:&quot;user registered&quot;
              })
          }
      }
      catch(err){
          console.log(err);
      }
  });
  
  module.exports = router;
  </code></pre>
  <p>this is my main file (server.js )</p>
  <pre><code>const express = require('express');
  const morgan = require('morgan');
  const colors = require('colors');
  const dotenv = require('dotenv');
  const mongoose = require('mongoose');
  const connectDB = require('./config/db');
  //creating main platform
  connectDB;
  console.log(mongoose.connection.readyState);
  const app = express();
  app.use(morgan('dev'));
  dotenv.config({
      path:'./config/config.env'
  })
  app.use(express.json({}))
  app.use(express.json({
      extended:true
  }))
  
  //creating server
  app.use('/api/todo/auth',require('./routes/user'));
  const Port = process.env.port;
  app.listen(Port,
      console.log(`listening on port :${Port}` .red.underline.bold));
  //creating req,res platform
  
  </code></pre>
  <p>but after running this it shows error while giving post request</p>
  <pre><code>MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
      at Timeout.&lt;anonymous&gt; (D:\nikunj\Programming\todoapp\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:20)
      at listOnTimeout (node:internal/timers:556:17)
      at processTimers (node:internal/timers:499:7)
  </code></pre>
  <p>pls find a solution for this. thanks .sorry if it is a silly or wrong question because I am new to this nodejs</p>