简体   繁体   中英

Rails/Nginx/Capistrano/Puma: (111: Connection refused) while connecting to upstream

I keep getting this error in the nginx.error.log:

2016/06/06 20:14:02 [error] 907#0: *1 connect() to unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock failed (111: Connection refused) while connecting to upstream, client: 50.100.162.19, server: , request: "GET / HTTP/1.1", upstream: "http://unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock:/", host: "appname.com"

(here it is with manually added newlines for your convenience)
2016/06/06 20:14:02 [error] 907#0: *1 connect() to
unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock failed
(111: Connection refused) while connecting to upstream, client: 
50.100.162.19, server: , request: "GET / HTTP/1.1", upstream: 
"http://unix:///home/user/apps/appname/shared/tmp/sockets/appname-
puma.sock:/", host: "appname.com"

This is my nginx.conf:

upstream puma {
  server unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock;
}

server {
  listen 80 default_server deferred;
  # server_name example.com;

  root /home/user/apps/appname/current/public;
  access_log /home/user/apps/appname/current/log/nginx.access.log;
  error_log /home/user/apps/appname/current/log/nginx.error.log info;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @puma;
  location @puma {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://puma;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 10M;
  keepalive_timeout 10;
}

What am I doing wrong? I followed Digital Ocean's tutorial to set up Capistrano, Nginx and Puma.

So the solution was to restart puma.

cap production deploy:restart

Every time I reboot the server, I need to restart puma as well.

My recommendation is to check

~/apps/appname/shared/log/puma.stderr.log

log file. You may find there the answer

查看log/puma_error.log我看到了错误(尝试加载捆绑器时的 LoadError),执行gem update --system修复了它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM