Why does omitting --authenticationDatabase "admin" cause refused connection?

For the “Creating First Application User” lab, I realized I could do everything right but if I leave off --authenticationDatabase "admin when starting up mongo I can create the user OK but on use admin > db.shutdownServer() > exit I start to see connection refusals/failures and when I go back to run validate_lab_first_application_user I get this:

Client experienced a timeout when connecting to the database - check that mongod is running on the correct port, and that the 'm103-application-user' user authenticates against the admin database.

I don’t recall --authenticationDatabase being covered in any previous tutorials.


By running

you did shutdown the server. So the server is not running anymore. That is why you have connection refusals/failures.

Although it wasn’t explicitly stated, some parts of the labs require independent research. This is probably one of those cases. You would have also already used authenticationDatabase in prior labs.

Yeah, other labs require more research which is fine by me–I learn quite a bit doing that. This was one of those times.

It’s confusing what db.shutdownServer() does, I thought it was part of stopping mongo but instead it shuts down mongod. When mongod is forked I can’t see its output either, which makes it harder to see what it’s doing.

Thanks for the help!


You can always refer to the documentation:
Mongod Config File Options

And the log files will usually contain more detailed information.

When I am unsure of something I google. In this case

Hi @Jeremy_16271,

I hope your doubts are clear now. Our documentation is a very rich source of information so, I would highly recommend you to refer documentation if you are not sure about any method or operator :slight_smile: .

Please let me know if still have any doubts.

Shubham Ranjan
Curriculum Services Engineer