I get this error when trying to connect to MongoClient.connect, but only when I'm online. As soon as I am online, without changing the code or even restarting mongoDB, my application connects every time.
AssertionError: null == {MongoError: failed to connect to server [localhost: 27017] on the first connection
My server.js looks like this:
var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');
var operations = require('./operations');
var url = 'mongodb://localhost:27017/myApp';
MongoClient.connect(url, function (err, db) {
assert.equal(null, err);
...
Run codeIf I just use > mongo in the terminal, it connects without problems even in offline mode. Am I missing something in the documentation?
source
share