title: Mongo DB and Node.js Connection error
body: <p>I am very new to the server side. I just started with node.js and mongodb.</p>
  
  <p>Example code:</p>
  
  <pre><code>var http = require('http');
  var mongoose = require('mongoose');
  
  http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});
  
    mongoose.connect('mongodb://localhost/bookmarks');
    var db = mongoose.connection;
    db.on('error', console.error.bind(console, 'connection error:'));
  
    db.once('open', function callback () {
      // console.log('Running');
  
      var Users = mongoose.model('users', { name: String, lastname: String, yas: Number,   yer:String });
  
      Users.find().lean().exec(function(err,users) {
        // console.log(JSON.stringify(users));
        var sonuc=JSON.stringify(users);
  
        console.log(sonuc);
        res.end(sonuc);
      });
    });
  }).listen(1337,'127.0.0.1');
  </code></pre>
  
  <p>When running my code, it works the first time, but when I try to refresh the page I get this error and there is no response:</p>
  
  <blockquote>
    <p>connection error: { [Error: Trying to open unclosed connection.] state: 1 }       </p>
  </blockquote>