MongoDB Authentication, what URI should I use ?

Posted November 2, 2015 3.9k views


I set username and password to mydatabase and can access with the following URI
URI ‘mongodb://username:password@ip:27017/mydatabase’

Now I want to protect the access to my MongoDB Server with Authentication=True with UserDB and password

For that, I use MongoChef to set the Authentication, User name and password
What is the URI that I should use to access mydatabase ?

I use KeyStoneJS on docker, MongoDB on Docker and NGINX on Docker for my website.

Thank You

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


The URI shouldn’t change with a modification such as this. As you still access it the same way, you just require authentication now.

Is that giving you issues? If so, what are the errors you are getting? It’s important to understand when asking for help to provide as much information as you can when looking for help. Otherwise we do not have the tools needed to replicate and help you.