MongoError: auth failed

I am trying to connect to mongodb from my web application using Mongooose [http://mongoosejs.com/]. However, I get an MongoError: auth failed from mongo when I specify the database I want to connect to. If I do not specify the db, then to connection is successful. It works when…