3 / 3
Nov 2024

Hi there,
I’ve got this issue while trying to connect to MongoDB Atlas.

First of all, I am new to MongoDB and node.js and I am willing to learn.

As network Access I set 0.0.0.0/0

Is anybody there who could help me solve this issue?

(node:88195) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(Use node --trace-warnings ... to show where the warning was created)
(node:88195) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version

const mongoose = require("mongoose"); const dotenv = require("dotenv"); dotenv.config(); mongoose.connect(process.env.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true, }); const db = mongoose.connection; db.on("error", console.error.bind(console, "connection error:")); db.once("open", () => { console.log("Connected to MongoDB Atlas"); }); module.exports = db;

As the warning indicates, those two client options are deprecated. You can just change your connection code to the following to clear those up:

mongoose.connect(process.env.MONGODB_URI);