In this MongoDB tutorial, let us see how to fix the error, “MongoDB shutting down with code 100“. We will also see the root cause of the issue.
Why shutting down with code 100 in MongoDB
While starting MongoDB, I recently got an error like “MongoDB shutting down with code 100“. It looks like below:
Basically, this problem occurred due to a permission issue with the data files or it is not finding the desired location of the file.
Also Read: How to install MongoDB
Solution: MongoDB shutting down with code 100
Now, let us see how to fix the Windows OS, macOS, and Ubuntu errors.
For Windows users to resolve this issue follow the below solution.
Sometimes when we start the MongoDB server, we got an error shutting down with code 100.
So, what causes it to exit with code 100?
One of the main reasons for the exit with code 100 is
- Incorrect file permission
- Missing database directory
Sometimes folder already exists in the system due to the previous installation. So if this is the reason for getting the error we need to delete all the content from the folder and then start the MongoDB server. This will resolve the problem.
For macOS users to resolve this issue use the following steps
- We need to create the “db” directory. Because mongo data files will store in this directory.
- We can create the diretory in the using this command
sudo mkdir -p /data/db
- we also have to provides right permission to the directory
sudo chown -R 'id -un' /data/db
- Now with the help of “sudo mongod” command we can succesfully start the mongo server.
- Note that it will not gonna work if you only use “mongod“.
For Ubuntu users to resolve this issue
This error shutting down with code 100 has occurred mainly due to a permission issue with the data files so to resolve this error we need to change the ownership to the MongoDB user,
sudo chown -R mongodb:mongodb /var/lib/mongodb
After running the command this will change the ownership and resolve the existing error of MongoDB. Now, we can successfully run the MongoDB server.
In this tutorial, we learned how to fix shutting down with code 100 in MongoDB.
Also, Read: Unable to locate package mongodb-org
After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a Microsoft MVP. Check out more here.