MongoDB - MongoError: connect ECONNREFUSED
<p>I keep getting an error when trying to connect mongoDB. I know there are many questions similar to this one and I have checked all of them and haven't found a solution for my issue.</p>

<p>Here is the exact error:</p>

<p>connection error: { MongoError: connect ECONNREFUSED 127.0.0.1:21017
name: 'MongoError'
message: connect ECONNREFUSED 127.0.0.1:21017</p>

<p>I looked at some other solutions and they say to adjust the mongo.conf file but I can't seem to find the file on my system and I've downloaded MongoDB.</p>

<p>Here is my full code:</p>

<pre><code>var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
$ = require('cheerio');

/* GET home page. */


mongoose.connect('mongodb://localhost/');


var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
    console.log('Connected to database');
  // we're connected!
});


var pageInfo = {
    title: 'JotIT',
    owner: 'Emmanuel Obogbaimhe',
    message: 'Hi welcome to JotIT. A quick, simple and easy to use note taker.',
    date: Date.now(),
    age: 22
};

router.get('/', function(req, res, next) {
  res.render('index', { 
    title: pageInfo.title,
    author: pageInfo.owner,
    message: pageInfo.message,
    date: pageInfo.date,
    age: pageInfo.age
     });
});



module.exports = router;
</code></pre>