Error
Error Code:
91
MongoDB Error 91: Server Shutdown Active
Description
Error 91 indicates that the MongoDB server instance is currently in the process of shutting down. This prevents new connections or operations from being accepted until the shutdown process completes or fails, ensuring data integrity during termination.
Error Message
Shutdown In Progress
Known Causes
3 known causesGraceful Server Shutdown
An administrator or automated system initiated a graceful shutdown of the MongoDB instance using a command like `db.shutdownServer()`.
Operating System Shutdown
The host operating system is being shut down or restarted, which consequently triggers the MongoDB process to terminate.
External Process Termination
The `mongod` process received a termination signal (e.g., SIGTERM) or was killed by an external process manager or script.
Solutions
4 solutions available1. Wait for Graceful Shutdown Completion easy
Allow the server to finish its shutdown process.
1
When you encounter this error, it means MongoDB is in the process of shutting down. This is often a planned event. Wait for a few moments to see if the shutdown completes naturally. If the shutdown was initiated by an administrator, it should eventually finish.
2
After waiting, try connecting to the MongoDB server again. If the shutdown was successful, the server should be available for new connections.
2. Check MongoDB Server Status and Logs medium
Investigate the cause of the shutdown by examining server status and logs.
1
Connect to the server where MongoDB is running. Check the status of the MongoDB service. The command will vary depending on your operating system.
sudo systemctl status mongod
2
If using older systems or different configurations, you might use:
sudo service mongod status
3
Examine the MongoDB log files for messages indicating the reason for the shutdown. Common log file locations include `/var/log/mongodb/mongod.log` on Linux or within the MongoDB data directory on Windows. Look for messages related to shutdown signals, errors, or administrative commands.
sudo tail -f /var/log/mongodb/mongod.log
4
If the shutdown was unexpected or due to an error, the logs will provide clues. You may need to restart the MongoDB service after addressing any identified issues.
sudo systemctl start mongod
3. Forcefully Restart MongoDB Service (Use with Caution) medium
Restart the MongoDB service if it appears stuck during shutdown.
1
If the server is unresponsive and you suspect it's stuck in a shutdown state, you can attempt to forcefully restart the MongoDB service. This should be done with caution as it can lead to data loss if the server was in the middle of a critical operation.
sudo systemctl restart mongod
2
Alternatively, you can stop and then start the service:
sudo systemctl stop mongod
sudo systemctl start mongod
3
After restarting, monitor the MongoDB logs (as described in Solution 2) to ensure it starts up correctly and to identify any potential lingering issues.
4. Investigate Administrative Shutdown Commands medium
Determine if an administrative shutdown command was issued.
1
If you have administrative access to the MongoDB instance, check for recent shutdown commands. This can be done by reviewing audit logs if enabled, or by checking the command history of users with administrative privileges.
2
In `mongosh` (or the legacy `mongo` shell), you can check the server status to see if a shutdown is pending or in progress. However, if the server is already in a shutdown state, you may not be able to connect to issue this command.
db.adminCommand({ serverStatus: 1 }).shutdownState
3
If a shutdown was intentionally initiated, wait for its completion. If it was unintentional, investigate who issued the command and why. If the shutdown was initiated via a cluster management tool or orchestration system (like Kubernetes), check the status and logs of that system.