Mongoose .find() method causes requests to hang

Until you call mongoose.connect, your mongoose queries will simply be queued up.

Add code like this in your startup code to connect:

mongoose.connect('mongodb://localhost/test', function(err) {
    if (err) {
        console.error(err);
    } else {
        console.log('Connected');
    }    
});

In the connection string, replace test with the name of your database.

Leave a Comment