502坏的网关:Nginx&gunicorn

我得到一个502错误,这里的nginx日志:

2015/09/04 15:25:31 [error] 1563#0: *1 connect() to unix:/home/90158/test/test.sock failed (111: Connection refused) while connecting to upstream, client: 142.29.143.200, server: hackerspace.sd72.bc.ca, request: "GET / HTTP/1.1", upstream: "http://unix:/home/90158/test/test.sock:/", host: "hackerspace.sd72.bc.ca" 

我是nginx / gunicorn的新手,需要知道我可以做什么旁边解决这个问题。

/home/90158/test/test.sock存在。

这里是我的nginx conf文件:

 server { listen 80; server_name hackerspace.sd72.bc.ca; access_log /var/log/nginx/test.access.log; error_log /var/log/nginx/test.error.log; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/90158/test/src; } location / { include proxy_params; proxy_pass http://unix:/home/90158/test/test.sock; } } 

这里是我的gunicorn conf文件:

 description "Gunicorn application server handling test_project" start on runlevel [2345] stop on runlevel [!2345] respawn setuid 90158 setgid www-data chdir /home/90158/test exec bin/gunicorn --workers 3 --bind unix:/home/90158/test/test.sock src/test_project.wsgi:application 

我究竟做错了什么?

后续步骤进行故障排除:

  • 该文件实际上是一个套接字?
  • 你的gunicorn服务器实际上是在监听socket吗?

根据unix (7),如果套接字不是“监听套接字”,则可以通过connect (2)返回ECONNREFUSED – 一种笨拙的方式,即“正在监听”。 “如果目标文件名不是套接字,也会发生此错误。”