Hi @dhairya_srivastava .
Welcome to The MongoDB Community Forums! ![]()
How did you check if the connection was successful? Did you get DB connection successfully in the logs?
As per your error, Error: MongooseError: Operation tours.insertOne() buffering timed out after 10, 10 seconds is the default buffer timeout and it generally happens when an operation is being performed without connecting to database.
Additionally, as per this documentation on mongoose
Mongoose lets you start using your models immediately, without waiting for mongoose to establish a connection to MongoDB.
That’s because mongoose buffers model function calls internally. This buffering is convenient, but also a common source of confusion. Mongoose will not throw any errors by default if you use a model without connecting.
So the issue could be that your model is being called before the connection is established. Please try using async/await with connect() as shown in Error Handling - Mongoosejs.
mongoose.connect('mongodb://localhost:27017/test').
catch(error => handleError(error));
// Or:
try {
await mongoose.connect('mongodb://localhost:27017/test');
} catch (error) {
handleError(error);
}
Regards,
Tarun