Windows: MongoDB.Driver.MongoCommandException - need to login

If you enable the MongoDB monitoring on Windows, you may see this error. 

MongoDB.Driver.MongoCommandException: Command 'serverStatus' failed: need to login (response: { "errmsg" : "need to login", "ok" : 0.0 }) 
at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType, IMongoCommand command) 
at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](String commandName) 
at MongoDB.Driver.MongoDatabase.RunCommand(String commandName) 
at BoxedIce.ServerDensity.Agent.Checks.ExtendedMongoDBCheck.DoCheck() 
at BoxedIce.ServerDensity.Agent.Agent.DoChecks()

This will happen if you have not appended (admin) to your username in your connection string. For example, if your connection was is: 

mongodb://user:pass@127.0.0.1:27017

you should replace it to be:

mongodb://user(admin):pass@127.0.0.1:27017
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.