Node app.js returns Error: connect ECONNREFUSED 127.0.0.1:27017
<p>This is what my app.js file looks like:</p>

<pre><code>var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');

// Connect to Mongoose
mongoose.connect('mongodb://localhost/bookstore');
var db = mongoose.connection;

app.get('/', function(req, res){
    res.send('Hello World!');
});

app.listen(3000);
console.log('Running on port 3000...');
</code></pre>

<p>When I do a node app, I get this error:</p>

<pre><code>~/node_modules/mongoose/node_modules/mongodb/lib/server.js:242
        process.nextTick(function() { throw err; })
                                      ^
Error: connect ECONNREFUSED 127.0.0.1:27017
    at Object.exports._errnoException (util.js:873:11)
    at exports._exceptionWithHostPort (util.js:896:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1077:14)
</code></pre>

<p>I have searched through StackOverflow, but all of the similar posts are just similar, but not specific to this one. I thought it may have been an issue with mongodb not being installed. I did a brew install mongodb and then I did a mkdir -p /data/db, then ran mongod, but I got an error there. I have not posted that error because frankly I don't even know if I am on the right track.</p>