MongoDB - Permission denied for socket: /tmp/mongodb-27017.sock

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

A

# ls -ld /tmp

will tell you.

If you're unsure try:

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

That might fix it.


Try changing owner like this,

sudo chown mongodb:mongodb /tmp/mongodb-27017.sock

we use mac and install mongodb, usually do not need mongodb.conf, so, try this:

sudo chown -R your-username /tmp/

ps:your-username is your username in mac os, not root.if you don't know what is your username,there's a command:

whoami