【发布时间】:2021-08-27 17:06:29
【问题描述】:
当我访问 http://[ip address] 时,收到 502 bad request 错误。
/etc/systemd/system/gunicorn.socket 文件:
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
/etc/systemd/system/gunicorn.service 文件:
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=mainuser
Group=www-data
WorkingDirectory=/home/mainuser/Personal_Web
ExecStart=/home/mainuser/Personal_Web/vr/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myapp.wsgi:application
[Install]
WantedBy=multi-user.target
/etc/nginx/sites-available/myapp 文件:
server {
listen 80;
server_name [ip address];
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/mainuser/Personal_Web;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
当我运行 sudo tail -F /var/log/nginx/error.log 时,我收到 connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream 错误。我不知道为什么我会得到这个或如何解决它?
【问题讨论】:
-
请显示“sudo systemctl status gunicorn.socket”和“sudo journalctl -u gunicorn.socket”的输出
-
第一个显示:
● gunicorn.socket - gunicorn socket Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled) Active: failed (Result: service-start-limit-hit) since Thu 2021-06-10 14:59:38 UTC; 2h 47min ago Triggers: ● gunicorn.service Listen: /run/gunicorn.sock (Stream)第二个命令显示:Listening on gunicorn socket. Failed with result 'service-start-limit-hit'.@EneP
标签: django nginx gunicorn digital-ocean