tvieira
tvieira

Reputation: 1915

Unicorn + Nginx Rails production error

I'm following this tutorial to deploy a RoR app with Capistrano but I'm getting an error in my production server

[error] 28314#0: *1 connect() to unix:/tmp/unicorn.myapp.sock failed (111: Connection refused) while connecting to upstream, client: xx.xxx.xx.xx, server: , request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.myapp.sock:/", host: "myapp.cloudapp.azure.com"

My /etc/nginx/sites-available/default

upstream app {
  # Path to Unicorn SOCK file, as defined previously
  server unix:/tmp/unicorn.myapp.sock fail_timeout=0;
}

server {

  listen 3000;
  server_name localhost;

  root /home/deploy/apps/myapp/current/;

  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;
}

I changed the server to many different things, but I get the exact same error, with the same host, server, upstream.

The problem was with Unicorn, somewhere in my Capistrano deploy, it wasn't restarting Unicorn as it should.

Upvotes: 0

Views: 927

Answers (1)

Mark Stosberg
Mark Stosberg

Reputation: 13381

Nginx logs indicate that this is an issue with the backend server. After your backend up is up and running. Check:

Once those tests pass, test again through Nginx.

Upvotes: 2

Related Questions