18

I use fedora 17, and when I setup nginx with uwsgi using unix domain socket, when I place the socket in a directory with proper permission it's ok, but when I place the socket in the /tmp it will cause nginx error:

connect() to unix:/tmp/MySite.sock failed (2: No such file or directory) while connecting to upstream

The file does exist and has read/write permission for nginx user. But what cause this error, its really drive me crazy, can somebody figure it out.

33

You can't place sockets intended for interprocess communication in /tmp.

For security reasons, recent versions of Fedora use namespaced temporary directories, meaning every service sees a completely different /tmp and can only see its own files in that directory.

To resolve the issue, place the socket in a different directory, such as /run (formerly known as /var/run).

  • /run is not writable for a regular user though – hostmaster Dec 12 '14 at 9:26
  • 1
    /run is not writable directly, but you can instruct systemd to create a directory under it which is writable by both processes. – Michael Hampton Mar 4 '15 at 13:04
  • To help those searching, this also applies to centos 7, and moving the socket-folder to /run worked. It's not easy to find this issue, because every account can see the folder and file in tmp (set 777 to test), so you'd never guess that processes could not. – JosephK Mar 30 at 11:23
0

YES! THIS HELPED!

Was seeing check-startup-logs messages from uwsgi, but had no data in the startup logs, wasn't able to find out what was happening. Turned out, I needed to change the sock file to a non-/tmp location, and add:

catch-exceptions = true

to the wsgi's ini file. turned out, I'd specified logging filehandler location to a non-existent directory, so it couldn't log the errors in the first place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.