/ mongodb

MongoError: auth failed

I am trying to connect to mongodb from my web application using Mongooose. 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 using mongo command line and mongodb management tool like Robomongo. Here is what we normally do.

var dbURI = 'mongodb://user:pwd@localhost:27017/dbname';

And an error will be like -

MongoError: auth failed
at Object.toError...

But I found a solution from MongoDB Node.js Driver. It only needs to add ?authSource=admin in the end of the line.



Ours is a cycle of hatred; alliances forged and broken. We have paid the price for sharing this world and we have forgotten what makes us strong.

Read More