0

Although I tried all suggested solutions in google? But the same error keep popup to me. I checked my mongoDB server and it's work fine. I replaced localhost to 127.0.0.1 and also to 0.0.0.0 but it still not working.

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://127.0.0.1:27017/mydb";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  console.log("Database created!");
  db.close();
});

  • Does this answer your question? [Can't connect to MongoDB 6.0 Server locally using Nodejs driver](https://stackoverflow.com/questions/74609210/cant-connect-to-mongodb-6-0-server-locally-using-nodejs-driver) – Wernfried Domscheit Apr 09 '23 at 05:02

0 Answers0