【问题标题】:Django Deploy to heroku: Application ErrorDjango部署到heroku:应用程序错误
【发布时间】:2020-08-08 04:16:42
【问题描述】:

我将我的 Django 项目部署到 heroku。它部署成功,但页面显示应用程序错误。在heroku的日志中错误是这样的。

2020-04-24T05:34:09.500250+00:00 app[web.1]: [2020-04-24 05:34:09 +0000] [4] [INFO] Using worker: sync
2020-04-24T05:34:09.506988+00:00 app[web.1]: [2020-04-24 05:34:09 +0000] [10] [INFO] Booting worker with pid: 10
2020-04-24T05:34:09.532649+00:00 app[web.1]: [2020-04-24 05:34:09 +0000] [11] [INFO] Booting worker with pid: 11
2020-04-24T05:34:10.051702+00:00 heroku[web.1]: State changed from starting to up
2020-04-24T05:34:20.000000+00:00 app[api]: Build succeeded
2020-04-24T05:34:26.126726+00:00 app[web.1]: [2020-04-24 05:34:26 +0000] [4] [INFO] Shutting down: Master
2020-04-24T05:34:41.808971+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dashboard-retail.herokuapp.com request_id=f5feaeba-075f-4dc7-a637-fe6b271f0d67 fwd="125.24.11.115" dyno=web.1 connect=1ms service=30003ms status=503 bytes=0 protocol=https
2020-04-24T05:34:42.096139+00:00 app[web.1]: [2020-04-24 05:34:42 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:10)

在Procfile中,我是这样设置的

web: gunicorn myWeb.wsgi --log-file -

请帮帮我。谢谢。

【问题讨论】:

    标签: python django heroku


    【解决方案1】:

    看起来 gunicorn 侦听了错误的端口,而不是 buildpack 等待的端口,因此您收到 503 错误。尝试将$PORT 添加到您的Procfile

    web: gunicorn myWeb.wsgi --log-file - --bind 0.0.0.0:$PORT
    

    【讨论】:

    • 感谢您的推荐,但我还是看到了同样的问题。我试试这样。 web: gunicorn myWeb.wsgi --log-file - --bind 127.0.0.1:8000
    • @atjab 0.0.0.0 表示“任何接口”,127.0.0.1 只会在 localhost 上侦听,这不是必需的。请尝试0.0.0.0
    • 我试过你的建议。这个端口运行Listening at: http://0.0.0.0:13953 ,但它仍然是同样的错误
    • 您找到解决方案了吗?我被同样的问题困扰了几个小时......
    • 你找到解决办法了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-05
    • 2021-09-22
    • 1970-01-01
    • 1970-01-01
    • 2013-12-25
    • 1970-01-01
    • 2018-08-18
    相关资源
    最近更新 更多