MongoDB shutdown option is unavailable? How to get it?

If the MongoDB shutdown option is unavailable, you need to switch to the admin database first. The shutdownServer() method requires administrative privileges and can only be executed from the admin database context.

Syntax

use admin
db.shutdownServer()

Step 1: Switch to Admin Database

First, connect to the admin database ?

use admin
switched to db admin

Step 2: Execute Shutdown Command

Now run the shutdown command ?

db.shutdownServer()
server should be down...
2019-04-22T19:11:40.949+0530 I NETWORK [js] trying reconnect to 127.0.0.1:27017 failed
2019-04-22T19:11:42.197+0530 I NETWORK [js] reconnect 127.0.0.1:27017 failed failed

Key Points

  • The shutdownServer() method only works from the admin database.
  • You must have administrative privileges to shut down the MongoDB server.
  • The reconnection failures in the output confirm the server has shut down successfully.

Conclusion

To access MongoDB's shutdown option, switch to the admin database using use admin, then execute db.shutdownServer(). This method requires admin privileges and will gracefully shut down the MongoDB server.

Updated on: 2026-03-15T00:52:05+05:30

126 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements