The shutdown command cleans up all database resources and then terminates the process. You must issue the shutdown command against the admin database in the form:

db.adminCommand({ shutdown: 1 })


Run the shutdown against the admin database. When using shutdown, the connection must originate from localhost or use an authenticated connection.

If the node you’re trying to shut down is a replica set primary, then the command will succeed only if there exists a secondary node whose oplog data is within 10 seconds of the primary. You can override this protection using the force option:

db.adminCommand({ shutdown: 1, force: true })

Alternatively, the shutdown command also supports a timeoutSecs argument which allows you to specify a number of seconds to wait for other members of the replica set to catch up:

db.adminCommand({ shutdown: 1, timeoutSecs: 60 })

The equivalent mongo shell helper syntax looks like this:

db.shutdownServer({timeoutSecs: 60});