7

When I try to start mongo db I get the following error:

Trying to run the command : ./mongod --dbpath=../data
Failed to unlink socket file /tmp/mongodb-27017.sock errno:13 Permission denied
Fatal Assertion 28578

As per the suggestions from other posts, have tried to locate the file /tmp/mongodb-27017.sock, to delete. But the file itself is not available.

But when I tried to do it using root, I am able to start the mongo DB. For normal users it fails.

Version used: mongodb-osx-x86_64-3.0.2

Gryu
  • 2,102
  • 2
  • 16
  • 29
mavlesreennap
  • 71
  • 1
  • 1
  • 2
  • Possible duplicate of ['Failed to unlink socket file" error in MongoDB 3.0](http://stackoverflow.com/questions/29813648/failed-to-unlink-socket-file-error-in-mongodb-3-0) – Cyril Duchon-Doris Mar 05 '16 at 15:32

3 Answers3

14

Remove file

/tmp/mongodb-27017.sock

/dbpath/mongod.lock

try start with any user not root user.

Community
  • 1
  • 1
Fariz Aghayev
  • 649
  • 5
  • 17
5

Current user does not have permissions to delete that file.

Grant permissions to the current user:

sudo chown `whoami` /tmp/mongodb-27017.sock

mon
  • 2,167
  • 1
  • 12
  • 6
1

The following steps work for me:

sudo rm /tmp/mongodb-27017.sock

sudo systemctl start mongod // wont start but will create .sock file again

sudo chown "[current user]" /tmp/mongodb-27017.sock

sudo systemctl start mongod // will start now

sudo systemctl status mongod // should show active