Failed to detach 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 virtual machine on a Windows 7 host. I have successfully installed MongoDB (packages, etc.), but when I execute the sudo service mongod start , I get the following error in the / var / log / mongodb / mongod.log. Can someone help me figure out this error. There is nothing on the Internet that is related to this.

2015-04-23T00: 12: 00.876-0400 i CONTROL ***** SERVER RESTARTED ***** 2015-04-23T00: 12: 00.931-0400 E NETWORK [initandlisten] Could not disconnect socket file / tmp / mongodb -27017.soc k errno: 1 Operation not allowed 2015-04-23T00: 12: 00.931-0400 i - [initandlisten] Fatal statement 28578 2015-04-23T00: 12: 00.931-0400 i - [initandlisten]

+54
mongodb
Apr 23 '15 at 4:24
source share
7 answers

I fixed this problem myself by deleting the mongodb-27017.sock . I started the service after deleting this file, which worked fine. However, I am still not sure about the root cause of the problem. The output of the ls - lat /tmp/mongodb-27017.sock now

 srwx------ 1 mongodb nogroup 0 Apr 23 06:24 /tmp/mongodb-27017.sock 
+126
Aug 03 '15 at 6:56
source share

An alternative answer provided by KurioZ7, you can simply set the permissions of the .sock file for the current user:

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

This does the trick for me if I want to run mongod without sudo. If I delete the file, as in KurioZ7s, answer, I just get the same error the next time I start my machine.

+22
Dec 15 '15 at 13:52
source share

The most likely reason for this was that the mongod process was at some point started by the root user. Therefore, the socket file (/tmp/mongodb-27017.sock) belonged to the root user. The mongod process usually runs under its own dedicated user, and this user did not have permission to delete this file.

The solution, as you already found out, was to remove it. Then mongodb was able to recreate it with the correct permissions. This should be preserved after a reboot if mongodb is started using initialization scripts or under the correct user account.

+9
Feb 22 '16 at 16:21
source share

This problem occurs if you use the command

 mongod 

Before using the command

 sudo service mongod start 

To fix the problem, follow these steps:

Set the appropriate permissions for the file:

 /tmp/mongodb-27017.sock 

OR

Delete file

 /tmp/mongodb-27017.sock 

Run

 sudo service mongod start && mongod 
+9
Dec 17 '17 at 23:24
source share
 $ sudo mongod 

he solves the problem for me

+4
Oct 09 '17 at 15:41
source share

For UNIX-based operating systems, as an alternative to the answer provided by Bastronaut, you can also specify a .sock file to save to a folder in which mongod has full user rights (according to how you use mongod), so mongod also will be able to delete the .sock file at shutdown. The default folder in which the .sock file is saved is '/ tmp'. To specify a different folder, use the custom mongodb configuration file, for example, "mongodb.conf", and add the following to it:

 net: unixDomainSocket: pathPrefix: "anotherFolder" 

After that, you can start mongod with the command:

 $ mongod --config /path/to/mongodb.conf 

You can read the documentation at: https://docs.mongodb.org/manual/reference/configuration-options/#net.unixDomainSocket.pathPrefix

+2
Mar 30 '16 at
source share

I am new to CentOS and MongoDB. When I give "Mongo" to start the daemon, I get the following error. Can someone please direct me to finding a solution for this. Try the following commands to try connecting it to the server. 1. sudo service mongod start 2. launch mongodb.service 3. sudo mongod everything was in vain !!

"2019-04-28T20: 07: 19.772 + 0530 E QUERY [thread1] Error: failed to connect to server 127.0.0.1:27017, connection attempt failed: connect@src/mongo/shell/mongo.js: 229: 14 @ (connection): 1: 6 "This is my error message

0
Apr 28 '19 at 14:42
source share



All Articles