MongoDB - socket permission: /tmp/mongodb-27017.sock

I had an unclean closure of MongoDB on Ubuntu 10.04 LTS. Now, when I log in as root and start Mongodb using the mongodb start service, I get below error-

Mon Dec 12 13:53:15 [initandlisten] ERROR: listen(): bind() failed errno:13 Permission denied for socket: /tmp/mongodb-27017.sock 

When I run MongoDB manually as root, it works fine.

I can confirm that there is no file / tmp / mongodb -27017.sock

 root@devbox:~# ll /tmp/ total 16 drwxr-xr-x 4 root root 4096 2011-12-12 13:53 ./ drwxr-xr-x 25 root root 4096 2011-12-11 13:06 ../ drwxrwxrwt 2 root root 4096 2011-12-12 13:01 .ICE-unix/ drwxrwxrwt 2 root root 4096 2011-12-12 13:01 .X11-unix/ 

Where to start troubleshooting?

+16
mongodb sockets file-permissions upstart
Dec 12 '11 at 18:58
source share
4 answers

What are the file permissions on / tmp? Is it possible that they have been changed?

BUT

 # ls -ld /tmp 

will tell you.

If you are not sure, try:

 # chown root:root /tmp # chmod 1777 /tmp 

It can fix it.

+15
Dec 12 '11 at 19:22
source share

Try changing the owner like this,

 sudo chown mongodb:mongodb /tmp/mongodb-27017.sock 
+17
Aug 09 '16 at 6:25
source share

Make sure the Ubuntu mongo user has access to the file. Mongo service Ubuntu uses an Ubuntu Mongo user. To find out the mongo username, change to the / var / lib / mongodb directory and show permissions: ls -l

0
Dec 12 '11 at 19:19
source share

I have the same problem because I am using run mongodb from root, it will start crashing with systemctl on CentOS 7.3.

Please use the correct permission for mongodb. $ sudo chown -R mongod:mongod \ /var/run/mongodb/mongod.pid \ /tmp/mongodb-27017.sock \ /var/lib/mongo/

If we have other crashes, such as Error reading file /path/file: Permission denied , maybe we can fix it with SELinux . $ sudo chcon -v -t mongod_var_lib_t /path/file

By the way, I do not recommend using permission 777, it is so dangerous .: P

0
Apr 13 '17 at 10:22 on
source share



All Articles