0

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....

1

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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