Connecting to MongoDB database on mLab fails authentication

Viewed 20688

I have a Parse app, and I'm trying to migrate my app's database to a MongoDB instance on mLab.

I already have a fork of Parse Server set up on Heroku, and I'm using Heroku's mLab MongoDB add-on.

I have a database on mLab called heroku_1ksph3jj, and I should be able to connect to it with the following template:

mongodb://<dbuser>:<dbpassword>@ds047124.mlab.com:47124/heroku_1ksph3jj

However, each attempt returns:

Server returned error on SASL authentication step: Authentication failed.

I'm unsure what to replace <dbuser> and <dbpassword> with. I have a database user with the same name as my database: heroku_1ksph3jjz, so I used that. And I used the password for that user in place of <dbpassword>. Should I have used something else here?

9 Answers

Just go to your Heroku dashboard and check your settings.

Under the name field there's a big button "Reveal Config Vars". Click it and you'll see a MONGODB_URI var with a uri to your db. It'll look something like this:

mongodb://heroku_user:PASSWORDyourLOOKINGfor@ds2238985.mlab.com:63295/heroku_user

Your password is right after the semicolon after the heroku user name.

Related