Rails/Nginx/Capistrano/Puma: 连接上游时发生 (111: Connection refused) 错误

6
我在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"

这是我的 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;
}

我做错了什么?我按照Digital Ocean的教程设置了Capistrano、Nginx和Puma。

3个回答

8
所以解决方案是重新启动puma。
cap production deploy:restart

每次我重启服务器,都需要重新启动puma。


1
在我设置了 linked_dirs 后仍然出现完全相同的错误,通过 cap production puma:restart 解决它,不确定原因。 - Spark.Bao
请为我解决 cap production puma:restart 的问题。谢谢。 - Massimo Alvaro

1
我的建议是检查。
~/apps/appname/shared/log/puma.stderr.log

日志文件。您可能会在那里找到答案。

0

查看 log/puma_error.log,我发现了错误(尝试加载 bundler 时出现 LoadError),执行 gem update --system 解决了问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接