Ask coding questions

← Back to all posts
Mongodb does not connect to port
sojs (295)
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]

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