MongoDB Authentication, what URI should I use ?

November 2, 2015 1.1k views
MongoDB Nginx Node.js Ubuntu


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

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.

Have another answer? Share your knowledge.