I am seeing one issue with node version 18.12.0 and mongodb 6.0.2. I already build a nestjs application with mongodb. Here I use @nestjs/mongoose(v- 9.0.2) and mongoose (v-6.7.0)
Here I can see that when I upgrade node js to latest lts version then I am not able to connect to mongodb. It show an error like unable to connect to database.
But When I downgrade to node version 16.18.0 then it working fine. My question is that you guys already face this issue or I am only person getting this issue. If you know that then actually where is the problem occurred?
Here is my connection code-
MongooseModule.forRoot("mongodb://localhost:27017/nekmart", {
connectionFactory: (connection) => {
connection.plugin(slug, { number: true });
return connection
}
}),
Had same problem after upgrading to NodeJs 18.12.1; followed other blogs/comments and apparently
changing the Uri from mongodb://localhost:27017/test_db to mongodb://127.0.0.1:27017/test_db works.
Without getting into the specifics reasons it appears that localhost is rejected due to some changes in NodeJS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With