0

Getting the following error when I tried to estalish connection to my MongoDB Atlas.

[nodemon] starting `node index.js`
Note-It backend listening at http://localhost:5000
(node:1928) UnhandledPromiseRejectionWarning: MongooseError: Operation `users.createIndex()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\Meet\OneDrive\Desktop\note-it-backend-api\backend\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:149:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1928) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1928) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
***********************Connected to MongoDB successfully***********************

I cant make any HTTP requests because of this

The db.js contents are :

const mongoose = require('mongoose');

// Connection string for MongoDB ATLAS
const mongoURL = "mongodb+srv://new-meeti:<password>@meet-dev.cc0qw.mongodb.net/?retryWrites=true&w=majority"

const connectToMongo = () => {
    // .connect method taks 2 args, 2nd one is a callback function
    mongoose.connect(mongoURL, () => {
        console.log("***********************Connected to MongoDB successfully***********************");
    })
}

module.exports = connectToMongo;

This was more than a year old project hosted on heroku but then I had to shift to to some other hosting service so again deploying is getting problematic due to various deprecation issues I think. A help would be really appreciated. Thanks :)

PS : I checked my Network access on the MongoDB Atlas and 0.0.0.0/0 (includes your current IP address) is active.

0 Answers0