I'm working on a Scala framework that wants to connect to a local MongoDB instance using the Mongo Java library, but fails. The URI it uses to connect is:
mongodb://user:pass@localhost:27017/mydb
This causes the following exception to be raised when I try to update a collection:
com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18}
However, if I extract the parameters from the URI and give them to the Mongo shell:
$ mongo -u user -p pass --host localhost --port 27017 mydb
...then it lets me in! Can anyone suggest why this might be?
Possibly but unlikely to be relevant: Everything was working fine in the original environment I ran my framework in, a Dell laptop running Ubuntu. Now I'm trying to run it on a Mac laptop running Ubuntu in Virtualbox. Everything should be virtually (ha) identical, but obviously isn't somehow.