title: Nginx cannot find unix socket file with Unicorn (no such file or directory)
body: <p>I am deploying a Rails 4 app to a Fedora 19 x64 server using Nginx and Unicorn. The problem is that I get an error when visiting the address: "We're sorry, but something went wrong."</p>
  
  <p>My Nginx error log (<code>/var/log/nginx/error.log</code>) shows:</p>
  
  <pre><code>2014/03/08 03:50:12 [warn] 23934#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
  2014/03/08 03:50:12 [warn] 23936#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
  2014/03/08 03:50:14 [crit] 23939#0: *1 connect() to unix:/tmp/unicorn.[app name].sock failed (2: No such file or directory) while connecting to upstream, client: [client IP], server: localhost, request: "GET /v1/industries/1.xml HTTP/1.1", upstream: "http://unix:/tmp/unicorn.[app name].sock:/v1/industries.json", host: "api.[app name].ca"
  </code></pre>
  
  <p>As far as I can see from this, Nginx is not aware that the socket exists. However, looking in <code>/tmp</code>, it does:</p>
  
  <pre><code>[root@localhost tmp]# ls
  unicorn.[app name].sock
  </code></pre>
  
  <p>I keep getting stuck at this point, no matter how I modify my Unicorn config file or my Nginx config file. Both are attacted:</p>
  
  <p><strong>/var/www/[app name]/config/unicorn.rb</strong>:</p>
  
  <pre><code>working_directory "/var/www/[app name]"
  pid "/var/www/[app name]/pids/unicorn.pid"
  stderr_path "/var/www/[app name]/log/unicorn.log"
  stdout_path "/var/www/[app name]/log/unicorn.log"
  listen "/tmp/unicorn.[app name].sock"
  worker_processes 2
  timeout 30
  </code></pre>
  
  <p><strong>/etc/nginx/conf.d/default.conf</strong>:</p>
  
  <pre><code>upstream app {
      server unix:/tmp/unicorn.[app name].sock fail_timeout=0;
  }
  server {
      listen 80;
      server_name localhost;
      root /var/www/[app name]/public;
      try_files $uri/index.html $uri @app;
      location @app {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          proxy_pass http://app;
      }
      error_page 500 502 503 504 /500.html;
      client_max_body_size 4G;
      keepalive_timeout 10;
  }
  </code></pre>
  
  <p>The way I have been starting these two daemons is as follows:</p>
  
  <pre><code>unicorn_rails -c /var/www/[app name]/config/unicorn.rb -D -E production
  service nginx start
  </code></pre>
  
  <p>The Unicorn logs contain no relevant information, nor do the production logs. This setup seems straight forward, has anyone experienced this before? Thanks for any help you can provide.</p>
  
  <p>By the way, I was initially following this tutorial: <a href="https://www.digitalocean.com/community/articles/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5">https://www.digitalocean.com/community/articles/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5</a></p>