Mongoose (node.js), unable to connect to [localhost: 27017]
I am trying to start the server, but I am getting the error:
Error: failed to connect to [localhost:27017]
at null.<anonymous> (C:\node\project\node_modules\mongoose\node_modules\mong
odb\lib\mongodb\connection\server.js:549:74)
at emit (events.js:106:17)
at null.<anonymous> (C:\node\project\node_modules\mongoose\node_modules\mong
odb\lib\mongodb\connection\connection_pool.js:150:15)
at emit (events.js:98:17)
at Socket.<anonymous> (C:\node\project\node_modules\mongoose\node_modules\mo
ngodb\lib\mongodb\connection\connection.js:533:10)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
Here is my code:
var debug = require('debug')('project');
var app = require('../app');
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
When I use "npm start" the server gets up for a second, but literally after that it goes down.
+3
source to share