9

I am unable to authenticate mongodb remotely. I'm running MongoDB 3.0.0 provided by the DigitalOcean One-Click installer, and I can't seem to set up authentication properly.

I have 1 database called wbio_production. I followed mongodb docs tutorials as best as I could. When I execute:

> db.auth("siteUserAdmin","MYPASSWORD")
1
> db.getUsers()

The output of that is:

{
    "_id" : "admin.siteUserAdmin",
    "user" : "siteUserAdmin",
    "db" : "admin",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ]
} 

And when I switch to the wbio_production database and perform the same getUsers():

> use wbio_production
switched to db wbio_production
> db.getUsers()
[
    {
        "_id" : "wbio_production.herokuUser",
        "user" : "herokuUser",
        "db" : "wbio_production",
        "roles" : [
            {
                "role" : "userAdmin",
                "db" : "wbio_production"
            },
            {
                "role" : "readWrite",
                "db" : "wbio_production"
            }
        ]
    }
]

When I fill out the connection form in Robomongo however, it cannot successfully connect to the database. Authorization always fails, however it does successfully connect to the database.

I have tried the following combinations of using the users above:

  1. DB: Admin, User: siteUserAdmin
  2. DB: Admin, User: herokuUser
  3. DB: wbio_production, User: siteUserAdmin
  4. DB: wbio_production, User: herokuUser

All of them wind up with some output coming back in the heroku logs similar:

failed with error 13: "not authorized for query on wbio_production.mongoid_forums_forums"

I have tried reinstalling mongodb, recreating users based off different tutorials, and just trying different peoples explanations. I've spent about 5 hours now looking for a solution to my issue, and now I must turn to SO for your advice. I'm sure this is a simple error on my part that I am not understanding from the docs or something I am continuously missing in the set up.

What must I do to get a secured and functional MongoDB server? Thanks!

4
  • How are you authenticating the user when you connect to mongo?
    – MForMarlon
    Commented Apr 14, 2015 at 17:16
  • A quick question, can I assume you are connecting via ssh to a mongo shell to execute your above mongo? If so, the fault may lie in robomongo, as I found this on their site: Note: We are working on an update with MongoDB 3.0 compatibility for the upcoming Robomongo 0.9.x release series. If this is the case I would recommend using the mongo shell to do what you need to and setting up mms (mms.mongodb.com) I believe it's free to give an oversight on your instance. NewRelic also has free plugins to do this.
    – ABrowne
    Commented May 1, 2015 at 5:45
  • You should definitely try connecting from the mongo shell so you have fewer layers between you and the database. Commented May 6, 2015 at 13:39
  • Have you verified the config in mongod.config file? Commented May 12, 2015 at 17:45

2 Answers 2

1

You need to configure mongod with its binding so clients can connect remotely.

bind_ip = 0.0.0.0
0

Robomongo authentication does not work with MongoDB 3+. I recommend switching over to MongoChef. http://3t.io/mongochef/. I highly recommend it, as it contains MANY more capabilities than Robomongo does.

Another thing to keep in the back of your mind...

If you are also using Mongoid, it is currently undergoing a large rewrite. Mongoid 5 will drop Moped https://www.mongodb.com/blog/post/announcing-ruby-driver-20-rewrite.

Take a look at my other answer on what to do if you are using Mongoid 4 with MongoDB 3+. Rails Mongoid fails to authenticate - failed with error 13: "not authorized for query on my_db.my_collection"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.