Search code examples
mongodbubuntu-13.04

'Failed to unlink socket file" error in MongoDB 3.0


I am new to MongoDB. I am trying to install MongoDb 3.0 on Ubuntu 13.0 LTS, which is a VM on Windows 7 Host. I have installed MongoDB successfully (packages etc.), but when I execute the command sudo service mongod start, I get the following error in the "/var/log/mongodb/mongod.log" log file. Can anyone help me understanding this error. There is nothing on internet related to this.

2015-04-23T00:12:00.876-0400 I CONTROL ***** SERVER RESTARTED ***** 2015-04-23T00:12:00.931-0400 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted 2015-04-23T00:12:00.931-0400 I - [initandlisten] Fatal Assertion 28578 2015-04-23T00:12:00.931-0400 I - [initandlisten]


Solution

  • I have fixed this issue myself, by deleting the mongodb-27017.sock file . I ran the service after deleting this file, which worked fine. However, I am still not sure the root cause of the issue. The output of the command ls - lat /tmp/mongodb-27017.sock is now

    srwx------ 1 mongodb nogroup 0 Apr 23 06:24 /tmp/mongodb-27017.sock
    

    The best option is not to delete the lock file

    Instead, check the file user and group user. Set both to the current user:

    • First run: whoami
    • Then run: sudo chown <output of the above command> /tmp/mongodb-27017.sock
    • Next run: sudo service mongod restart && sudo mongod