title: Can't start MongoDB on localhost for node.js
body: <p>I am a beginner to node.js and MongoDB. I am trying to setup a basic project like so.</p>
  
  <p>In my project dir I run <code>node init</code>, accept the default values and then run <code>npm install --save mongodb</code>. In my index.js I have the following code:</p>
  
  <pre><code>// Import the mongodb module
  var mongo = require('mongodb');
  
  var MongoClient = require('mongodb').MongoClient;
  var url = "mongodb://localhost:3333/mydb";
  
  MongoClient.connect(url, function(err, db) {
    if (err) throw err;
    console.log("Database created!");
    db.close();
  }); 
  </code></pre>
  
  <p>Now when I run <code>node index.js</code> I get the following error:</p>
  
  <p><code>failed to connect to server [localhost:3333] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:3333]</code></p>
  
  <p>I have tried changing the port number but still get the same error. What am I doing wrong here?</p>