Django 502带gunicorn&;德扬戈

Django 502带gunicorn&;德扬戈,django,nginx,deployment,gunicorn,Django,Nginx,Deployment,Gunicorn,我正在使用gunicorn和nginx部署django项目。我的nginx设置是 server { listen 8000; server_name 0.0.0.0; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/gagan/saporawebapp; } location / { include proxy_para

我正在使用gunicorn和nginx部署django项目。我的nginx设置是

server {
listen 8000;
server_name 0.0.0.0;

location = /favicon.ico { access_log off; log_not_found off; }

location /static/ {
        root /home/gagan/saporawebapp;
}

location / {
        include proxy_params;
        proxy_pass http://unix:/home/gagan/saporawebapp/saporawebapp.sock;
}
}
当我跑的时候

sudo nginx -t
这表明设置是正确的。然后我开始使用gunicorn

gunicorn --daemon --workers 3 --bind unix:/home/gagan/saporawebapp/saporawebapp.sock saporawebapp.wsgi
然后nginx显示502坏网关。相应的错误日志为

2019/10/08 07:51:34 [emerg] 3988#3988: open()     "/etc/nginx/sites-enabled/saporawebapp" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2019/10/08 07:59:54 [crit] 4278#4278: *1 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET /signup/ HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/signup/", host: "157.245.108.160:8000"
2019/10/08 08:05:19 [crit] 4278#4278: *5 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET /signup/ HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/signup/", host: "157.245.108.160:8000"
2019/10/08 08:06:24 [crit] 4744#4744: *1 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET /signup/ HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/signup/", host: "157.245.108.160:8000"
2019/10/08 08:14:47 [alert] 5279#5279: 768 worker_connections are not enough
2019/10/08 08:14:47 [error] 5279#5279: *763 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 157.245.108.160, server: 0.0.0.0, request: "GET /signup/ HTTP/1.0", upstream: "http://157.245.108.160:8000/signup/", host: "157.245.108.160:8000"
2019/10/08 09:49:53 [crit] 11601#11601: *1 connect() to unix:/home/gagan/saporawebapp/saporawebapp.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET / HTTP/1.1", upstream: "http://unix:/home/gagan/saporawebapp/saporawebapp.sock:/", host: "157.245.108.160:8000"

你能提供gunicorn日志吗
sudo service gunicorn status
可能会给您一些线索。@Toankocho此命令提供了
gunicorn.service not found
但我不是从服务脚本使用gunicorn哦,我明白了,看起来您是在手动启动gunicorn。我想你可以停止gunicorn的进程。。尝试在没有守护进程标志的情况下运行它,查看是否有来自gunicorn的响应。@Toankocho在这种情况下,gunicorn工作正常。我猜主要错误是由于缺少.sock文件。您能提供gunicorn日志吗
sudo service gunicorn status
可能会给您一些线索。@Toankocho此命令提供了
gunicorn.service not found
但我不是从服务脚本使用gunicorn哦,我明白了,看起来您是在手动启动gunicorn。我想你可以停止gunicorn的进程。。尝试在没有守护进程标志的情况下运行它,查看是否有来自gunicorn的响应。@Toankocho在这种情况下,gunicorn工作正常。我猜主要错误是由于缺少.sock文件