Mongodb, mongoLab, Heroku (staging) and rails : Authentication fail

131 views Asked by At

I work on a project deployed on Heroku, with production and staging version. When I want to access to the mongo shell on staging writing this line : mongo <host/app> -u <username> -p <password> (with <> remplaced with my informations) I have this error :

2016-12-21T11:34:43.861+0100 E QUERY    [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20
@(auth):6:1
@(auth):1:2

exception: login failed

It work for production but not for staging. And when I want to do a mongorestore with all informations I have this error :

Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed

Does someone could help me ?

2

There are 2 answers

0
pneumee On

Are the MongoDB server versions for production and staging different? If so, you'll probably need a different version of the client tools. Best to match major versions to avoid issues. Eg 3.0.x server requires at least 3.0.x client tools, 3.2.x server requires at least 3.2.x client tools, etc.

0
hbrannan On

Check to make sure your user permissions are correctly set & try passing in your authenticationDatabase as well mongo <host:port> -u "root" -p "123456" --authenticationDatabase <"admin">.

I'm not familiar w/ the SASL setup, but more specifics are available here.