Empty reply from server error in CURL with node.js, express and mongoDB

I am getting the error "Empty reply from server" In CURL, when I try to run "http://localhost:3000/light"

var express = require('express'),
    values = require('./routes/values');

var app = express();

app.get('/light', values.findAll);

app.listen(3000);
console.log('Listening on port 3000...');

and my values.js is

var mongo = require('mongodb');

var Server = mongo.Server,
    Db = mongo.Db,
    BSON = mongo.BSONPure;

var server = new Server('localhost', 27017, {auto_reconnect: true});
db = new Db('sensordb', server);

db.open(function(err, db) {
    if(!err) {
        console.log("Connected to 'sensordb' database");
        db.collection('values', {safe:true}, function(err, collection) {
            if (err) {
                console.log("The 'values' collection doesn't exist. Creating it with sample data...");
                populateDB();
            }
        });
    }
});

exports.findAll = function(req, res) {
    db.collection('values', function(err, collection) {
        collection.find().toArray(function(err, items) {
            res.send(items);
        });
    });
};

var populateDB = function() {

    var values = [
    {
        value: "10",
        date: "121212",
        time: "1214"
    },
    {
        value:  "12",
        date: "121212",
        time: "1224"
    }];

    db.collection('values', function(err, collection) {
        collection.insert(values, {safe:true}, function(err, result) {});
    });

};

Well basically in the above code, I create a database and if the database is empty, I try to populate it. When I run the server code on my terminal I also get something like:

=  Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowlegement                                                       =
=     journal: true/false, wait for flush to journal before acknowlegement             =
=     fsync: true/false, wait for flush to file system before acknowlegement           =
=                                                                                      =
=  For backward compatibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   http://www.mongodb.org/display/DOCS/getLastError+Command                           =
=                                                                                      =
=  The default of no acknowlegement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================

Is the above error causing some problem? If so, what? if not, what is responsible?

Any help would be really appreciated.

It seems that your populateDB function uses the global db variable, while the opened db is a different variable, given as parameter to the callback you provide when opening the database. This is caused since you have two different variables called db, each visible in a different scope and refers to a different object. To make the picture clearer, I added a parameter to your populateDB function, and created db1, db2 callback parameters. The modifications below should help:

db.open(function(err, db1) {
...
                populateDB(db1);

...
var populateDB = function(db2) {
...
    db2.collection('values', function(err, collection) {
        collection.insert(values, {safe:true}, function(err, result) {});
    });

};