Main Tutorials

MongoDB – Failed to unlink socket file /tmp/mongodb-27017

Upgraded MongoDB and unable to start the mongod process, review the /var/log/mongodb/mongod.log file, and found the following error messages :

Terminal

2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] MongoDB starting : pid=31927 port=27017 dbpath=/var/lib/mongodb3 64-bit host=hcompass
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] db version v3.2.16
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] git version: 056bf45128114e44c5358c7a8776fb582363e094
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1t  3 May 2016
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] allocator: tcmalloc
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] modules: none
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] build environment:
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten]     distmod: debian71
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten]     distarch: x86_64
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten]     target_arch: x86_64
2017-08-24T03:57:21.289-0400 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,192.168.x.x" }, storage: { dbPath: "/var/lib/mongodb3" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2017-08-24T03:57:21.311-0400 E NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-08-24T03:57:21.311-0400 I -        [initandlisten] Fatal Assertion 28578
2017-08-24T03:57:21.311-0400 I -        [initandlisten]

***aborting after fassert() failure

Check the /tmp/mongodb-27017.sock permission, owner is root?

Terminal

$ ls -ls /tmp/mongodb-27017.sock
0 srwx------ 1 root root 0 Aug 24 03:56 /tmp/mongodb-27017.sock

P.S Debian 7 and MongoDB 2.6 –> upgraded to –> 3.2.16

Solution

To fix it, delete the /tmp/mongodb-27017.sock file manually and start the mongod process. Check the /tmp/mongodb-27017.sock permission again, the ownership is changed to the ‘mongodb’ user.


$ sudo rm -rf /tmp/mongodb-27017.sock
$ sudo service mongod start
[ok]

$ ls -lsah /tmp/mongodb-27017.sock
0 srwx------ 1 mongodb mongodb 0 Aug 24 04:01 /tmp/mongodb-27017.sock 
Common error
While sudo apt-get upgrade, Debian helps to upgrade the MongoDB automatically, and changed the mongodb-27017.sock ownership to root, and normally we start the ‘mongod’ process with user ‘mongodb’, and caused this “Operation not permitted”.

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
19 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Rafael
4 years ago

Hi mkyong, I applied your solution but when I try to start the service it keeps happening again. Any suggestion? Thanks

Luis Paulo Almeida
5 years ago

Tks!! I burning my brain with this error.

srinivas
6 years ago

This solution has saved my day. Thanks.

sam
2 years ago

Thanks. This really helped after hours of scratching my head.

Eric
3 years ago

Thank you the first ressource which actually helped!

Kiran Waghmore
3 years ago

Thank you, That was useful.

mani
3 years ago

It worked, thanks

MAtias
3 years ago

Thanks!!

nassim
3 years ago

thank you that helped

younes
3 years ago

how we can solve this permanently ?

cristhian
3 years ago

Muchas gracias amigo!

Tiago Mitef
3 years ago

Thank you my brother. Solved my problem,

abhishek
4 years ago

Thanks!

Apurva A Kunkulol
4 years ago

Awesome solution!! Thanks a tonne.

Brendan Wilding
4 years ago

Thank you! Helped me out. Cheers!

sameer
4 years ago

Thanks you

brong
5 years ago

good

Johnny
5 years ago

tks a lotttt!!!

Andrew Milko
6 years ago

Thank you very much for the solution!