Nginx cannot find unix socket file with Unicorn (no such file or directory) Nginx cannot find unix socket file with Unicorn (no such file or directory) unix unix

Nginx cannot find unix socket file with Unicorn (no such file or directory)


After many hours and a grand total of 3 beers, I've managed to figure out the problem. After hours of digging, I finally came across this Server Fault answer

In layman terms, it appears that programs that create files in /tmp (or /var/tmp as I have discovered) are the only programs that are able to see the files in that directory. Unicorn was creating the UNIX socket file, however Nginx could not see it.

The solution I have employed is to have Unicorn create sockets in /var/sockets.


I suddenly had a similar situation after changing nginx to use a systemd startup service based on their template.

It ends up that the problem was with PrivateTmp=true, which makes it so that nginx was unable to access the socket file created by gunicorn. Once I changed this to PrivateTmp=false the error resolved.