Fix Issue Can’t Start Mongo

Didik Mulyadi
2 min readApr 13, 2024

--

Photo by Sarah Kilian on Unsplash

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

sudo systemctl status mongod

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

  1. Make sure the key iskeyFile , not KeyFile .
  2. Make sure the keyfile.txt exists.
  3. Don’t put the file in the root , it will show permission denied when Mongo accesses the keyfile.txt inside the root. Move the file to the home/ directory.
  4. Update the keyfile.txt permission, run this command to give the owner access to the MongoDB user, and make sure it has read-only access cd ~/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 .

--

--