Mongod – Failed to unlink socket file /tmp/mongodb-27017


what am I to so?, I am a noob to mongo , sorry. But I need help.I was trying to fix it by myself for almost 2 hours now, but no progress

Hi @arsanyos_asrat,

Welcome to the MongoDB Community forums :sparkles:

It seems to be a permission issue. You can check the permission to the mongodb-27017.sock file using the following command.

ls -ls /tmp/mongodb-27017.sock

Please share the output of this command with us to assist you better!

~ Kushagra

This is the output that I recieved

0 srwx------ 1 mongodb mongodb 0 Mar  3 11:14 /tmp/mongodb-27017.sock

And thank you for reaching out , appreciate it.

Hi @arsanyos_asrat,

I will suggest you to

Remove the temporary socket with this command:

sudo rm -rf /tmp/mongodb-27017.sock

And then, Restart mongo daemon with sudo:

sudo service mongod restart

I hope it works!

Thanks,
Kushagra

It didn’t work, now when I run

sudo systemctl status mongod it return:
× mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-03-03 13:05:12 EAT; 2min 4s ago
       Docs: https://docs.mongodb.org/manual
    Process: 82949 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
   Main PID: 82949 (code=exited, status=14)
        CPU: 33ms

Mar 03 13:05:12 madmanlacy systemd[1]: Started MongoDB Database Server.
Mar 03 13:05:12 madmanlacy systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Mar 03 13:05:12 madmanlacy systemd[1]: mongod.service: Failed with result 'exit-code'.

But used to choose success with the green dot and all,
In addition , the mongod command returns the same error at the top of our discussion

mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-03-03 13:11:59 EAT; 2s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 83416 (mongod)
     Memory: 157.1M
        CPU: 811ms
     CGroup: /system.slice/mongod.service
             └─83416 /usr/bin/mongod --config /etc/mongod.conf

Mar 03 13:11:59 madmanlacy systemd[1]: Started MongoDB Database Server.

… it now showing when I run sudo systemctl start mongod,

Does this mean, I don’t need to run mongod… and just type on mongo and use the database functionalities and use the default port 20107 or whatever is specified in the mongodb.conf file?

apologies for bombarding you with questions with no break.

Hi @arsanyos_asrat,

As per your system status, mongod seems to be in an active state (running)

So, you can just hit mongo and use the DB with the default port.

~ Kushagra

I appreciate all the help, have a good day Kushagra_Kesav.

2 Likes