Mongodb service is in failed state

the above image gives the status

State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096*
LISTEN 0 128*
LISTEN 0 4096*
LISTEN 0 511*
LISTEN 0 4096*
LISTEN 0 4096*
LISTEN 0 128*
LISTEN 0 4096*
LISTEN 0 4096*
LISTEN 0 4096*
LISTEN 0 4096 [::]:9191 [::]:*
LISTEN 0 4096 [::]:8080 [::]:*
LISTEN 0 511 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 4096 [::]:6080 [::]:*
LISTEN 0 4096 [::]:6081 [::]:*
LISTEN 0 4096 [::]:6082 [::]:*
LISTEN 0 100 *:9090 :
output of the command ssn -tlnp

root 804843 1 0 07:12 ? 00:00:07 mongod --fork --logpath /var/lib/mongodb/mongodb.log --dbpath /var/lib/mongodb
root 805223 805199 0 07:14 pts/2 00:00:00 tail -100f /var/log/mongodb/mongod.log
output for ps -aef | grep [m]ongod

srwx------ 1 root root 0 Mar 27 07:12 /tmp/mongodb-27017.sock
output for the command ls -l /tmp/mongodb-*

Looks like you started mongod as root?
That tmp file should not be owned by root
Fix the file/dir permissions and start the service again with sysctl

Hi @Gowtham_Chendra,
do the checks suggested by @Ramachandra_Tummala, and paste the configuration file here, coz i think there is something wrong inside.

also here it looks like you have already launched a mongod process from the command line:

And you are trying to pull up the mongo service via systemctl when it is actually already running a mongod process launched from the command line.

it’s not very clear to me what you’re trying to do.


Thank you for the reply, I changed the owner, but the mongod service is not started, it is in failed state only. Sir, do you have any other solution…

Did you check permissions,/ownership of dbpath,logpath dirs?
You can start mongod from command line giving different port,dbpath,logpath dirs but you need to use the port number while connecting
Start mongod as normal user not as root
Check mongodb documentation on how to start mongod from command kine

Changed the owner from root to mongodb sir. The mongod.service is still in failed state. I tried to start/stop/enable/disable/restart, but nothings works

Check mongod.log on why it is failing
Did you take care of both dirs & tmp file?

ls -la /var/log/mongodb/mongod.log
-rw------- 1 mongodb mongodb 4549510 Mar 27 12:19 /var/log/mongodb/mongod.log

db path:
drwxr-xr-x 4 mongodb mongodb 12288 Mar 27 12:08 mongodb

socket file in tmp dir
srwx------ 1 mongodb mongodb 0 Mar 27 12:19 mongodb-27017.sock


I don have any idea what to do sir…

Hi @Gowtham_Chendra ,
please, attach the output of ps -ef | grep mongo.
Another information you can attach is cat /etc/passwd | grep mongo


Hi its my bad, I have changes owner for the particular file only, but need to change owner for the entire directory.

Now the service is running. But I can not able to connect the DB in MongoDBcompass… May I know the reasons and solution. I can able to connect with mongoDB locally…

hi @Gowtham_Chendra,
check if the bind_ip is set correctly and if the firewall rules are set correctly.


Sorry Fabio, after disabling the ufw, I can able to connect with mongoDB using MongoDB Compass. Now every thing is working fine.

Issue: What ever I do, the mongoDB service state is failed.

The complete solution is which works for me is:

sudo ufw status (if it is active need to disable)
systemctl stop mongod
sudo chown -R mongodb:mongodb /var/lib/mongodb/
chown mongodb:mongodb mongodb-27017.sock
systemctl start mongod
systemctl status mongod

@Gowtham_Chendra ,
Perfect, mark the solution in the last answer🤓

Done and provided complete solution which Works for me @Fabio_Ramohitaj and @Ramachandra_Tummala … Thank you for your help…

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.