connect ECONNREFUSED 127.0.0.1:27017'

mongodb, node.js

Solution

I was also facing the same issue, when I was executing `node server` on my project directory. For me the MongoDB service was not started, that makes this issue.

So I had to run `services.msc` and activated the service.

After that I was able to run my command.

D:\SVenu\MyApp>node server
Saving User
App is listening on port: 3000
Already Exist
Already Exist
Already Exist
Already Exist
Done save

Problem

I have that code: ``` var express = require('express'), stylus = require('stylus'), logger = require('morgan'), bodyParser = require('body-parser'), mongoose = require('mongoose'); var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development'; var app = express(); function compile(str, path){ return stylus(str).set('filename', path); } app.set('views', __dirname + '/server/views'); app.set('view engine', 'jade'); app.use(logger('dev')); app.use(bodyParser.urlencoded({ extended: true })); app.use(stylus.middleware( { src: __dirname + '/public', compile: compile } )); app.use(express.static(__dirname + '/public')); mongoose.connect('mongodb://localhost/multivision'); var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error..')); db.once('open', function callback(){ console.log('multivision db opened'); }); app.get('/partials/:partialPath', function(req, res){ res.render('partials/' + req.params.partialPath); }); app.get('*', function(req, res) { res.render('index'); }); var port = 3131; app.listen(port); console.log('Listening on port ' + port + '...'); ``` but when I'm trying `nodemon server.js` it throws an error: connection error.. { [MongoError: connect ECONNREFUSED 127.0.0.1:27017] name: 'MongoError' message: 'connect ECONNREFUSED 127.0.0.1:27017' } how can I improve that? I've already installed mongoose using `npm install mongoose --save` in my directory Yeah there are dozens question like this but none of these helped me.. I'm new at nodejs and probably missing something

Original source