33

I can't start mongoDB with the command "sudo systemctl start mongod".

I'm getting the following message :

● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2020-02-19 22:39:00 CET; 2s ago
     Docs: https://docs.mongodb.org/manual
  Process: 29368 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
 Main PID: 29368 (code=exited, status=14)

Feb 19 22:39:00 pop-os systemd[1]: Started MongoDB Database Server.
Feb 19 22:39:00 pop-os systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Feb 19 22:39:00 pop-os systemd[1]: mongod.service: Failed with result 'exit-code'.

I've already reinstalled mongodb and I having the same problem. I don't know where the error came from if you can help me. Thank you.

Joundill
  • 5,418
  • 11
  • 31
  • 47
Donastien
  • 331
  • 1
  • 3
  • 4
  • Its always good practice is to check the logs first and find out the actual cause. Here is the log location `/var/log/mongodb/` – Muhammad Tariq Mar 05 '21 at 05:50

8 Answers8

97

Just do those two commands for temporary solution:

sudo rm -rf /tmp/mongodb-27017.sock
sudo service mongod start

For details:

That shall be fault due to user permissions in .sock file, You may have to change the owner to monogdb user.

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock

For more details visit Documentation for installation

alper
  • 2,299
  • 4
  • 36
  • 73
Mohamed Sabry
  • 1,513
  • 7
  • 8
24

I had the same problem in Manjaro and these commands solved it:

chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock
HosseinNedaee
  • 380
  • 3
  • 6
15

This worked for me and I don't reinstall MongoDB. I have created manually

sudo mkdir /var/lib/mongodb
sudo mkdir /var/log/mongodb

and changed owner for both

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
7

These two commands solve the problem for me(Linux Mint 20.2).

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
Mr. Kabir
  • 119
  • 1
  • 2
3

This will worked for you and don't reinstall MongoDB.

sudo mkdir /var/lib/mongodb
sudo mkdir /var/log/mongodb

then run these commands

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb

start mongod service

sudo service mongod start 

mongod.service will be active

sudo service mongod status
MHAMMED TALHAOUY
  • 788
  • 6
  • 10
3

This error happend to me because of the ownship of the .sock file just try these two command

chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock

now restart the mongo server-

sudo systemctl start mongod

now you can check the status of mongo server with the following command -

sudo systemctl status mongod
0

These 3 steps solved my problem:

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
Sudarshan
  • 1
  • 2
  • 2
0

sudo mongod --dbpath /var/lib/mongodb/ --journal

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 10 '21 at 16:22