Starting the Database

In order to use Mongoose you must establish a connection with your database.

Here is a boilerplate module I use to initialize the database. var mongoose = require('mongoose'); module.exports = { _db: null, init: function{ if (!module.exports._db){ var path = 'mongodb://' + SERVER_NAME + '/' + DB_NAME; console.log('connecting to MONGO via ' + path); module.exports._db = mongoose.connect(path); }        return module.exports._db; } } The constants are set by global in a central bootstrapping function: module.exports.init = function(app) { global.SERVER_NAME = 'localhost:27017'; global.DB_NAME = 'glitterwood'; // obviously localized to my app - choose your own require('./../models/db').load; You only have to init your database once on application startup.