mongoose: New Mongoose error suddenly due to MongooseError: Buffering timeout
Prerequisites
- I have written a descriptive issue title
 
Mongoose version
8.2
Node.js version
18.x
MongoDB version
5.x
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Issue
Error
MongooseError: Operation `autodeletes.findOne()` buffering timed out after 10000ms at Timeout.<anonymous> (C:\Users\alban\documents\github\autodelete-v14\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:186:23) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7)
What I’ve done after research :
- Restart my vps :clown:
 - Give access to my IP separately than just have the 0.0.0.0
 - Try to connect via compass and check if there is any issues (no issues)
 - Try to find different ways to connect but nothing seemed to do anything.
 
Right now, I am using mongoose on node.js , I havent touched the code for a while and this cam up yesterday, as a result my app will not work.
the simple way I use to connect :
    if (mongoose.connection.readyState === 0) {
      try {
        console.log(`${ChalkAdvanced.blue('Database: ')} ${ChalkAdvanced.gray('>')} ${ChalkAdvanced.yellow('connecting...')}`);
        await mongoose.connect(`${mongoUrl}`, { serverSelectionTimeoutMS: 5000 }); // Increased timeout
        if (mongoose.connection.readyState === 1){
        console.log(`${ChalkAdvanced.blue('Database: ')} ${ChalkAdvanced.gray('>')} ${ChalkAdvanced.green('Successfully connected')}`);
      } else {
        console.log(`STATE OF THE DB HEREEEEEEEEEEEE : ${mongoose.connection.readyState}`)
      } 
      } catch (err) {
        console.error(err);
      }
    } else {
      console.log('Already connected to database.');
    }
  }```
About this issue
- Original URL
 - State: closed
 - Created 4 months ago
 - Comments: 19 (3 by maintainers)
 
Does the connection appear on the dashboard of mongoose??
the console.logs are printing that its connecting succesfully, and then the error pops, after a few seconds