Im trying to start mongod. I run "sudo service mongod start", but I get:

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

Theres a question here but I have tried all solutions to no avail https://stackoverflow.com/questions/29813648/failed-to-unlink-socket-file-error-in-mongodb-3-0

When I run "ls -ld /tmp" I see:

drwxrwxrwt 3 root root 4096 Jun  1 18:20 /tmp

When I run "ls -l /tmp/mongodb-27017.sock" I see:

srwx------ 1 mongod mongod 0 Jun  1 18:20 /tmp/mongodb-27017.sock

Mongod needs to be run with sudo, otherwise I get a permissions error. The problem started when I moved the /var/lib/mongo folder, then moved it back where it was. Now Mongod wont start.

Im on AWS EC2...

EDIT I've tried:

sudo chown mongod:mongod /tmp/mongodb-27017.sock

Same error.

Tried deleting the file, same error. Tried:

# chown root:root /tmp
# chmod 1777 /tmp

Same error....


This worked for me:

  1. Remove the temporary socket: rm /tmp/mongodb-27017.sock
  2. Restart mongo daemon with sudo: sudo service mongod restart

Then, the logs announces mongo is initialized and listening on port 27017 and mongo shell can connect.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.