How to solve the “Failed to unlink socket file” error in MongoDB

Stefan Ledin
1 min readMar 8, 2018

--

So I discovered that my Node application learnresponsiveimages.com suddenly had stopped working.

After at bit of research, it seemed like it actually was my MongoDB server that had stopped working. It just wasn’t running anymore.

I ran sudo service mongod status and got this, not very helpful message:

So I checked the /var/log/mongodb/mongod.log file and found this error:

Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted

The solution was to simply delete that file.

rm /tmp/mongodb-27017.sock

Problem solved and sudo service mongod start made it work again ✌🏻

--

--

Stefan Ledin

Web developer who makes fast WordPress sites with clean code and awesome backends. Also, JavaScript is nice!