1
Mar 27 16:13:41 localhost systemd[1]: Started MongoDB Database Server.
Mar 27 16:13:42 localhost systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Mar 27 16:13:42 localhost systemd[1]: mongod.service: Failed with result 'exit-code'.
root@localhost:~# systemctl restart mongod
root@localhost:~# systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2021-03-27 16:13:55 UTC; 1s ago
       Docs: https://docs.mongodb.org/manual
    Process: 8778 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
   Main PID: 8778 (code=exited, status=14)

Mar 27 16:13:54 localhost systemd[1]: Started MongoDB Database Server.
Mar 27 16:13:55 localhost systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Mar 27 16:13:55 localhost systemd[1]: mongod.service: Failed with result 'exit-code'.

Attempted solution: Switching owners

Commands Run
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart
sudo systemctl status mongod

Still failed regardless of restarts and switching owners

3
  • What is the output of journalctl -xe?
    – Kulfy
    Mar 27, 2021 at 16:27
  • pastebin.com/jq7d7WFe Mar 27, 2021 at 16:34
  • Can you check if there is any error in log file /var/log/mongodb/mongod.log ?
    – KK Patel
    Mar 28, 2021 at 18:59

3 Answers 3

1

In my case, therefor I install mongodb 4.0 so when I remove it but not data then mongodb 5 can not use this. These is my steps:
1. sudo tail -40 /var/log/mongodb/mongod.log and read somes log relative to mongodb "This version of MongoDB is too recent to start up on the existing data files. Try MongoDB 4.2 or earlier."
2. cd /var/lib/mongodb and remove all items
3. Run sudo mongod --repair --config /etc/mongod.conf
4. Run sudo chown -R mongodb:mongodb /var/lib/mongodb
5. Run sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
6. Run sudo systemctl start mongod
7. Run sudo systemctl status mongod
If above dont work, try this: sudo mongod
And everything work.

0
0

I suffered from the same problem. I installed MongoDB-org a couple of times and every time my system reboots it failed to restart the MongoDB server.

What I found that the problem was something with the startup. So I reinstalled the MongoDB-org following this documentation and didn't run sudo systemctl enable mongod which is for running MongoDB automatically on startup. And everything work fine.

Although the downside is that you have to start the MongoDB server every time you do logout or reboot the system by sudo systemctl start mongod.

0

So I created a data/db folder and this fixed the issue immediately

1
  • Where did you create it? Oct 9, 2021 at 8:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .