Mongodb can't start serivce- fixed.

mtee profile image Margaret W.N ・1 min read

Running sudo systemctl status mongod resulted in this error.

Alt Text

Here is how i fixed this on ubuntu 20.04.

From image above the mongod service is disabled so let's enable that first using the sudo systemctl enable mongod.

To fix the issue changing the default port worked for me. Info about the port can be found in the mongod.conf in the etc directory. You need to need root permission to edit this file on ubuntu.

We can use sudo gedit to open the text editor and edit as a super user. From the text editor we open the .conf file in the etc directory and change the port no from 27017 which is the default to 27020 (can be anything else).

Save the changes and close the file.

Run sudo systemctl start mongod to start mongodb.

And sudo systemctl status mongod to verify that mongodb is active. You should get the following output.

Alt Text

If this doesn't work for you here are some links to solutions i tried that didn't work for me:
Changing Permissions
Changing bindIp
Changing Security Settings

Happy fixing!

Posted on by:

mtee profile

Margaret W.N


Developer | GADs 20 scholar | Diving into backend


markdown guide