1. Updated Mongoose Version
I installed a stable version of Mongoose:
npm install [email protected]
2. Updated My MongoDB Connection Code const mongoose = require('mongoose');
const connectDB = async () => { try { await mongoose.connect("mongodb+srv://:@cluster0.4yklt.mongodb.net/?retryWrites=true&w=majority"); console.log('✅ MongoDB Connected'); } catch (error) { console.error('❌ Connection Error:', error.message); } };
connectDB();
Replace , , and with your actual MongoDB Atlas credentials.
3. Allowed IP Address in MongoDB Atlas To allow connections from your machine:
Log in to MongoDB Atlas.
Go to Network Access under Security.
Click "Add IP Address".
Choose "Add Current IP Address".
Click Confirm and wait for the status to become Active.