Ask coding questions

← Back to all posts
Mongodb does not connect to port
sojs (82)
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/mydb";

MongoClient.connect(url, function(err, db) {
  if (err) throw err
});

Results in:
Process crashed with: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]

Can anybody explain why it does not connect to the port?

Voters
sojs (82)