[DEP0170] DeprecationWarning: The URL mongodb://<USERNAME>:<PASSWORD>@ac-4hlp44x-shard-00-01.nqjamzn.mongodb.net:27017,ac-4hlp44x-shard-00-02.nqjamzn.mongodb.net:27017,ac-4hlp44x-shard-00-00.nqjamzn.mongodb.net:27017/<DATABASE>?authSource=admin&replicaSet=atlas-g8a2vr-shard-0&retryWrites=true&w=majority&ssl=true is invalid. Future versions of Node.js will throw an error.
2 Likes
Hey have you fixed this problem? Currently I am facing the similar problem
2 Likes
Hi I think I read something related Receive DEP0170 when connecting MongoDB Atlas with Node.js 20.3.1 - Stack Overflow, I think they’re saying it’s because of the numerous :, making node thinking it’s port numbers.
1 Like
AMAN_Vijay
(Aman Vijay)
4
Facing the same issue,is there any solution for this?
I keep getting the same erro while trying to deploy my node js project on render.com
1 Like
alexbevi
(Alex Bevilacqua)
7
Which version of the Node.js Driver are you using? Ignore this, we found the info we needed (see below)
alexbevi
(Alex Bevilacqua)
8
Note that after a bit of digging we’ve filed NODE-5802 for this issue. For anyone watching this thread the issue only affects 3.x of the driver (and any version of Mongoose that pins a 3.x version of the driver).
Upgrading to 4.x+ will address this warning.
Never mind. I was using a mongodb driver of version 2.x. I upgraded to 3.x and the issue was resolved. Thanks for the response.
saraEl
(Sara)
10
I encountered the same issue and resolved it it this way :
I uninstalled the mongoose and mongodb packages.
Afterward, I installed the latest version of mongoose using this command:
npm install mongoose@latest
Upon encountering this error:
“connection error: MongoParseError: options usecreateindex, usefindandmodify are not supported at parseOptions”.
I updated my mongoose connection method. Now, it looks like this:
mongoose.connect(dbUrl);
As a result, everything is now working well.
3 Likes
I wanted to add to the discussion for those who came to this thread after searching for a solution. I made the above updates to “mongoose” and was still getting the error message.
I forgot that I was also connecting using a MongoDB transport for Winston.
If you are using “winston-mongodb” don’t forget to add options:
winston.add(
new winston.transports.MongoDB({
db: 'mongodb://localhost/vidly',
level: 'error',
options: { useUnifiedTopology: true },
})
);
I have a similar situation to yours:
winston.add(
new winston.transports.MongoDB({
level: 'info',
db: process.env.DATABASE,
collection: 'info_logs',
options: {
useUnifiedTopology: true,
},
})
);
But I had the error:
[DEP0170] DeprecationWarning: The URL mongodb://<USERNAME>:<PASSWORD>@ac-4hlp44x-shard-00-01.nqjamzn.mongodb.net:27017,ac-4hlp44x-shard-00-02.nqjamzn.mongodb.net:27017,ac-4hlp44x-shard-00-00.nqjamzn.mongodb.net:27017/<DATABASE>?authSource=admin&replicaSet=atlas-g8a2vr-shard-0&retryWrites=true&w=majority&ssl=true is invalid. Future versions of Node.js will throw an error.
1 Like
Update to latest for Winston, MongoDb, Mongoose. Then run “npm ci” , this cleared everything up for me.
i had the same problem this is caused by old version of mongoose
just update mongoose and it well be solved
npm install mongoose@latest
1 Like
Had the same error when connecting loopback 4
Below is my configuration
const config = {
name: ‘mydatasource’,
connector: ‘mongodb’,
url: ‘mongodb+srv://username********@developing.cpd3inw.mongodb.net/todos’,
host: ‘’',
port: ‘’,
user: ‘’,
password: ‘’,
database: ‘testdb’,
useNewUrlParser: true
};
Hi everyone!
To solve this issue, first install the latest version of mongo by running: npm i mongo@latest
Then, remove the options passed to the MongoClient connect.
` const connection = await MongoClient.connect(mongoDBURL)````
(node:18412) [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
(Use node --trace-warnings ... to show where the warning was created)
node : 20.16.0
npm : 10.8.1
mongoose : 8.5.2
Error Msg
(node:88445) [DEP0170] DeprecationWarning: The URL mongodb://user:pass@bycdigital-shard-00-00.9cgp0.mongodb.net:27017,bycdigital-shard-00-02.9cgp0.mongodb.net:27017,bycdigital-shard-00-01.9cgp0.mongodb.net:27017/?authSource=admin&replicaSet=atlas-9xtpry-shard-0&retryWrites=true&w=majority&appName=BYCDigital&ssl=true is invalid. Future versions of Node.js will throw an error.
How can solve it ?
did you install the mongodb driver ?
npm i mongodb
Downgrading the node version from 22 to 14 worked for me
just update mongoose and it well be solved
npm install mongoose@latest