problem description
Mongodb is successfully installed under Mac. Opening localhost:27017 shows that It looks like you are trying to access MongoDB over HTTP on the native driver port.
command mongo can enter the database, and show dbs can display admin/config/local database
Connect mongodb
node code
let MongoClient = require("mongodb").MongoClient;
let url = "mongodb://localhost:27017/test";
MongoClient.connect(url, function(err, db) {
if (err) throw err;
console.log("");
db.close()
})
always make mistakes
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017]
checked, saying that mongo did not start, but I have already started
start command
mongodb --dbpath
mongo // show dbs
