Whenever I run my index.js file on webstorm, I get the following error:
process.nextTick(function() { throw err; })
^
Error: connect ECONNREFUSED 127.0.0.1:27017
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
Process finished with exit code 1
This is my index.js file:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/cats');
app.use (bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
var cats = require('./cat_routes.js')(app);
var server = app.listen(3000, function(){
console.log('running at 3000');
});
I am learning side by side with some tutorials, but this is a very strange error that I don't really understand.