Nginx cannot find unix socket file with Unicorn Nginx cannot find unix socket file with Unicorn nginx nginx

Nginx cannot find unix socket file with Unicorn


So finally got the system up and running, and for all the people facing similar problems, and without munch knowledge of unicorn or nginxhere are the steps:

First make sure both services are running (unicorn is the app server and nginx is the http server), both services should be configured in /etc/init.d/.

Stop both services.

Check your policies in selinux, here is a good question on how to do it for the same error in PHP nginx error connect to php5-fpm.sock failed (13: Permission denied), the idea is to be sure selinux isn't interfering with the read process of the socket (the socket is created by unicorn and read by nginx)

then you have to edit your config files unicorn.rb and nginx.conf, both should point to a folder different to tmp for the socket here is why https://serverfault.com/questions/463993/nginx-unix-domain-socket-error/464025#464025

So finally my configurations looks like this:

Part of nginx config file

upstream unicorn {  server unix:/home/myuser/apps/myapp/shared/socket/unicorn.camicase.sock fail_timeout=0;}

part of unicorn config file

listen "/home/deployer/apps/stickystreet/shared/socket/unicorn.camicase.sock"

then start unicorn and nginx, if you get a (13: Permission denied) while connecting to upstream error just do a sudo chmod 775 socket/ changing the socket for whatever folder you put your unicorn socket to be stored, then restart the nginx service.