0
votes

I'm try to run my rails apps on production (vps).

I'm using rbenv, unicorn, nginx, os ubuntu server..

I have config unicorn and nginx :

file : config/unicorn.rb

app_dir = "/home/axx/apps/axx"

working_directory "/home/axx/apps/axx"
pid "/home/axx/apps/axx/tmp/pids/unicorn.pid"
stderr_path "/home/axx/apps/axx/unicorn/unicorn.log"
stdout_path "/home/axx/apps/axx/unicorn/unicorn.log"

listen "/home/axx/apps/axx/tmp/sockets/unicorn.axx.sock"
worker_processes 2
timeout 30

file : /etc/nginx/sites-available/default

upstream app_server {
  server unix:/home/axx/apps/axx/tmp/sockets/unicorn.axx.sock fail_timeout=0;
}

server {
  listen 80;
  server_name localhost;

  root home/axx/apps/axx/public;

  location / {
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    if (-f $request_filename/index.html) {
      rewrite (.*) $1/index.html break;
    }

    if (-f $request_filename.html) {
      rewrite (.*) $1.html break;
    }

    if (!-f $request_filename) {
      proxy_pass http://app_server;
      break;
    }
  }
}

but when I access my site, I get 502 error. Also I go check unicorn and nginx :

nginx/error.log

connect() to unix:/home/axx/apps/axx/tmp/sockets/unicorn.axx.sock failed (111: Connection refused) while connecting to upstream,

I try to search some questions in this site and also googling too, but I can't solve my problem.

2
It looks like unicorn cannot create the sock.. Is this just permissions?errata
@errata I have updated my question, now I got 111 : connection refuseditx
unicorn process is not properly forked...Check application name and there paths too. Also I am assuming that you made similar changes in sites-enabled too, if not please create Symbolic link of sites-available to sites-enabled.RockStar

2 Answers

0
votes

Check your /etc/nginx/nginx.conf file and path for your unicorn.sock file. In my case I was missing current folder directory name.

0
votes

check your server unix:/home/axx/apps/axx/tmp/sockets/unicorn.axx.sock path in upstream block. You might be missing the correct path as I was missing current folder name.