Fix Issue Can’t Start Mongo
From real experience, I faced several error types of MongoDB when I started it, this article provides some solutions for those errors and I will update this article when I face a new error and solve it.
The error usually happens after you modify the Mongo config or delete the Mongo lock, to get the detail error we can use
tail -f /var/log/mongodb/mongod.log
, It will show the latest error
Error Status 14
This error might happen when you delete the lock file or change the permission
You only need to update the permission to fix that by running this command
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
After that, restart the Mongo service sudo systemctl restart mongod
and check the status sudo systemctl status mongod
.
Error Status 1/Failure After Add KeyFile
If you set up a Mongo replica set in a VPS and prepare a key file, then you skip to assign permission, you might face this error
- Make sure the key is
keyFile
, notKeyFile
. - Make sure the keyfile.txt exists.
- Don’t put the file in the
root
, it will show permission denied when Mongo accesses thekeyfile.txt
inside the root. Move the file to thehome/
directory. - Update the
keyfile.txt
permission, run this command to give the owner access to the MongoDB user, and make sure it has read-only accesscd ~/mongo-keyfile && sudo chown mongodb:mongodb keyfile.txt && chmod 400 keyfile.txt
After that, restart the Mongo service sudo systemctl restart mongod
and check the status sudo systemctl status mongod
.
Thank you for reading this article! 🚀
Reach me on Linkedin: https://www.linkedin.com/in/didikmulyadi/