title: Node.js MongoDB Sockets closed error
body: <p>I'm currently making a login system for my NodeJS application. However, I get a strange error from MongoDB whenever I try retrieving a collection.</p>
  
  <p><strong>Error Message</strong></p>
  
  <pre><code>[MongoError: server localhost:27017 sockets closed]
  name: 'MongoError',
  message: 'server localhost:27017 sockets closed'
  </code></pre>
  
  <p>Heres my code to connect to my db</p>
  
  <pre><code>    var username = req.body.user.username;
      var password = req.body.user.password;
  
      MongoClient.connect("mongodb://localhost:27017/myDb", function(err, db){
          assert.equal(null, err);
  
          var collection = db.collection("accounts");
          collection.findOne({"username": username}, function(err, item){
              console.log(item);
              console.log(err);
          });
  
          db.close();
      });
  </code></pre>
  
  <p>Is anyone able to see where Ive gone wrong?</p>