Reputation: 2450
AssertionError: null == {"name":"MongoError","message":"connect ECONNREFUSED"}
I got an AssertionError.
I try to use NodeJS AND MongoDB and I'm following tutorial from Github.
I got that error from this code below :
var MongoClient = require('mongodb').MongoClient
, assert = require('assert');
console.log(1);
// Connection URL
var url = 'mongodb://localhost:27017/myproject';
// Use connect method to connect to the Server
MongoClient.connect(url, function(err, db) {
console.log(2);
assert.equal(null, err);
console.log(3);
console.log("Connected correctly to server");
db.close();
console.log(4);
});
console.log(5);
At console, 1,5,2 is marked.
I installed assertion module. What is the problem?
I executed 'mongod' (actually I don't know if I did it correctly). After executing, 1,5,2 is marked, before that, 1,5,2 is not marked and got an error.
Upvotes: 1
Views: 3595
Reputation: 632
In order to run the server mkdir -p /data/db
then sudo mongod
and it should all be working well.
Upvotes: 1
Reputation: 3038
Judging from the ECONNREFUSED, I would say your server is not running. If you are running it from console, try re-starting it.
Upvotes: 2