Question

Mongodb not working Need Help ASAP

So I’ve reinstalled and installed mongo multiple times, but it isn’t working.

 sudo systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset>
     Active: failed (Result: exit-code) since Sun 2022-07-31 02:01:08 UTC; 4min>
       Docs: https://docs.mongodb.org/manual
   Main PID: 8278 (code=exited, status=14)

Jul 31 02:01:08 ku-node-backend systemd[1]: Started MongoDB Database Server.
Jul 31 02:01:08 ku-node-backend systemd[1]: mongod.service: Main process exited>
Jul 31 02:01:08 ku-node-backend systemd[1]: mongod.service: Failed with result >

I can go into the mongo console.

 mongo
MongoDB shell version v4.2.21
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("52ac93f3-defd-4570-84b7-cbe0495b45bc") }
MongoDB server version: 4.2.21

 mongo --eval 'db.runCommand({ connectionStatus: 1 })'
MongoDB shell version v4.2.21
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("f92d3c19-228e-41d7-b3c1-3a7a4ea9f54b") }
MongoDB server version: 4.2.21
{
        "authInfo" : {
                "authenticatedUsers" : [ ],
                "authenticatedUserRoles" : [ ]
        },
        "ok" : 1
}


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 22, 2022

Hello,

Do you see any errors in your MongoDB error log? You can check the log with the following command:

tail -f /var/log/mongodb/mongodb.log

Usually, you could try and remove the lock file and restart the service which in some cases fixes the startup error:

  • Remove the lock file:
sudo rm /var/lib/mongodb/mongod.lock
  • Repair the service:
mongod --repair
  • Start the service:
sudo systemctl start mongodb

Best,

Bobby