【问题标题】:Django app deployed to Digitalocean 502 Bad GatewayDjango 应用程序部署到 Digitalocean 502 Bad Gateway
【发布时间】:2018-08-22 08:44:50
【问题描述】:

我已将我的 django 应用程序(在本地运行)复制到 Digitalocean 的一个 droplet,我已在其中安装了 django 1-click 应用程序。 我得到 502 Bad Gateway 并且无法理解为什么。

2018/03/13 22:25:06 [error] 2104#2104: *44 upstream prematurely closed connection while reading response header from upstream, client: 139.162.251.201, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/django/gunicorn.socket:/"
2018/03/13 22:28:19 [error] 2104#2104: *46 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 93.55.242.118, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "46.101.7.245"
2018/03/13 22:31:51 [error] 2104#2104: *49 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 93.55.242.118, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "46.101.7.245"
2018/03/13 22:32:05 [error] 2104#2104: *52 connect() to unix:/home/django/gunicorn.socket failed (111: Connection refused) while connecting to upstream, client: 93.55.242.118, server: _, request: "GET /admin HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/admin", host: "46.101.7.245"
2018/03/13 22:40:18 [error] 2104#2104: *55 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 93.55.242.118, server: _, request: "GET /admin HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/admin", host: "46.101.7.245"
2018/03/13 22:40:23 [error] 2104#2104: *55 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 93.55.242.118, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "46.101.7.245"
2018/03/13 22:44:08 [error] 2104#2104: *59 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 93.55.242.118, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "46.101.7.245"
2018/03/13 22:44:08 [error] 2104#2104: *62 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 93.55.242.118, server: _, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/robots.txt", host: "46.101.7.245"
2018/03/13 22:56:30 [error] 2104#2104: *64 connect() to unix:/home/django/gunicorn.socket failed (111: Connection refused) while connecting to upstream, client: 93.55.242.118, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "46.101.7.245"
2018/03/13 22:58:36 [error] 2104#2104: *67 connect() to unix:/home/django/gunicorn.socket failed (111: Connection refused) while connecting to upstream, client: 93.55.242.118, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "46.101.7.245"

我是 Django 和部署到服务器的新手,我无法理解错误。我一直在寻找答案,但找不到适合我的解决方案。有没有办法获得更详细的错误?谢谢

【问题讨论】:

  • DigitalOcean 有很好的部署 Django 的教程。你看过他们吗?看起来 gunicorn 的服务不正确。

标签: python django nginx digital-ocean


【解决方案1】:

在您发布的日志中显示 upstream: "http://unix:/home/django/gunicorn.socket:/" - 看起来您的 Nginx 服务器配置错误,无法连接到 Django 应用程序。

确保将 Nginx 设置为连接到套接字 (unix:/...) 或 Django 应用提供流量的 http 端点。

【讨论】:

    猜你喜欢
    • 2021-06-22
    • 2020-06-12
    • 1970-01-01
    • 2020-06-12
    • 2020-02-06
    • 1970-01-01
    • 2017-06-05
    • 2022-01-16
    • 2019-07-27
    相关资源
    最近更新 更多