Django:Heroku 启动失败,at=error code=H10 desc="App crashed"

Django: Heroku Failing to launch, at=error code=H10 desc="App crashed"

试图在 Heroku 上启动一个应用程序,在过去的几周里,我似乎无法克服这个错误。我正确设置了我的存储库,所有内容都通过 git 推送到 Heroku,然后当我通过给我的 link 打开我的网站时,我看到了应用程序失败错误消息。我查看了我的日志,但似乎无法破译错误的来源或如何开始调试。如果有人可以提供帮助,那就太棒了!谢谢!

我的日志如下:

2015-02-02T04:01:38.814574+00:00 heroku[web.1]: Starting process with command `gunicorn indie_app.wsgi`
2015-02-02T04:01:39.881951+00:00 app[web.1]: Traceback (most recent call last):
2015-02-02T04:01:39.881989+00:00 app[web.1]:     sys.exit(run())
2015-02-02T04:01:39.882016+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-02-02T04:01:39.881966+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-02-02T04:01:39.882149+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
2015-02-02T04:01:39.882183+00:00 app[web.1]:     Arbiter(self).run()
2015-02-02T04:01:39.882250+00:00 app[web.1]:     self.manage_workers()
2015-02-02T04:01:39.882055+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-02-02T04:01:39.882129+00:00 app[web.1]:     super(Application, self).run()
2015-02-02T04:01:39.882077+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
2015-02-02T04:01:39.882210+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 169, in run
2015-02-02T04:01:39.882270+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
2015-02-02T04:01:39.882356+00:00 app[web.1]:     self.spawn_workers()
2015-02-02T04:01:39.882376+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 542, in spawn_workers
2015-02-02T04:01:39.882473+00:00 app[web.1]:     time.sleep(0.1 * random.random())
2015-02-02T04:01:39.882563+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2015-02-02T04:01:39.882493+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
2015-02-02T04:01:39.882652+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-02-02T04:01:39.882741+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-02-02T04:01:39.882542+00:00 app[web.1]:     self.reap_workers()
2015-02-02T04:01:40.654279+00:00 heroku[web.1]: Process exited with status 1
2015-02-02T04:01:40.673618+00:00 heroku[web.1]: State changed from starting to crashed
2015-02-02T04:01:40.674364+00:00 heroku[web.1]: State changed from crashed to starting
2015-02-02T04:01:50.369085+00:00 heroku[web.1]: Starting process with command `gunicorn indie_app.wsgi`
2015-02-02T04:01:52.540605+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
2015-02-02T04:01:52.540682+00:00 app[web.1]:     super(Application, self).run()
2015-02-02T04:01:52.540719+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
2015-02-02T04:01:52.540770+00:00 app[web.1]:     Arbiter(self).run()
2015-02-02T04:01:52.540800+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 169, in run
2015-02-02T04:01:52.540859+00:00 app[web.1]:     self.manage_workers()
2015-02-02T04:01:52.540886+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
2015-02-02T04:01:52.541011+00:00 app[web.1]:     self.spawn_workers()
2015-02-02T04:01:52.541038+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 542, in spawn_workers
2015-02-02T04:01:52.541156+00:00 app[web.1]:     time.sleep(0.1 * random.random())
2015-02-02T04:01:52.541181+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
2015-02-02T04:01:52.541248+00:00 app[web.1]:     self.reap_workers()
2015-02-02T04:01:52.541276+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2015-02-02T04:01:52.541383+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-02-02T04:01:52.541508+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-02-02T04:01:52.540589+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-02-02T04:01:52.540379+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-02-02T04:01:52.540315+00:00 app[web.1]: Traceback (most recent call last):
2015-02-02T04:01:52.540502+00:00 app[web.1]:     sys.exit(run())
2015-02-02T04:01:52.540530+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-02-02T04:01:53.479723+00:00 heroku[web.1]: Process exited with status 1
2015-02-02T04:01:53.497538+00:00 heroku[web.1]: State changed from starting to crashed
2015-02-02T04:01:53.908609+00:00 heroku[api]: Scale to web=1 by egbe@usc.edu
2015-02-02T04:02:04.383428+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=salty-refuge-1024.herokuapp.com request_id=1abfe0da-fbd2-45f8-bd2f-52b5423acf6b fwd="24.228.44.221" dyno= connect= service= status=503 bytes=
2015-02-02T04:02:04.774497+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=salty-refuge-1024.herokuapp.com request_id=bf481dcb-e6d2-4620-b19c-982b5bd3d531 fwd="24.228.44.221" dyno= connect= service= status=503 bytes=
2015-02-02T04:02:04.689179+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=salty-refuge-1024.herokuapp.com request_id=46733f84-e2b4-4b0a-9733-e70cbc0f2d95 fwd="24.228.44.221" dyno= connect= service= status=503 bytes=

heroku 似乎无法启动网络服务器,因此将应用程序状态更改为崩溃。每当我收到此错误代码时,Procfile 配置错误或有错误。

gunicorn 软件包未安装时(在您的 virtualenv 中)会发生同样的错误。这是截至 2016 年 10 月的类似回溯:

2016-10-21T08:35:56.041002+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/" host=mygreatapp.herokuapp.com 
request_id=blablabla fwd="188.73.193.22" dyno= connect= service= 
status=503 bytes=

我非常不耐烦,在将本地应用程序转换为 Heroku 应用程序期间(包括创建 Procfileruntime.txt.gitignore 文件、安装 dj-database-url, whitenoise) 我忘了安装最重要的包 (pip install gunicorn)!!!

这样做,H10 error消失了!

干杯!

我也遇到了类似的问题 然后更改 Procfile 并且它有效 以前

web: gunicorn django_project.wsgi

已编辑

web: gunicorn django_project.wsgi:application --log-file - --log-level debug
python manage.py collectstatic --noinput
manage.py migrate

添加 gunicorn requirement.txt 完成!! 我因为这个错误浪费了一个小时。

确保你有 Procfile:

web: gunicorn --bind 0.0.0.0:$PORT project_name:app

记得ip应该是0.0.0.0

并使用 gunicorn 添加需求文件。

由于新的 whitenoise 配置,我遇到了这个错误。我更改了它,现在可以使用了。

您的 WhiteNoise 配置与 WhiteNoise v4.0 不兼容 2020-08-22T08:14:04.757895+00:00 app[web.1]:这可以通过以下升级说明进行修复: 2020-08-22T08:14:04.757895+00:00 应用[web.1]: 查看此站点以获取新配置 => http://whitenoise.evans.io/en/stable/changelog.html#v4-0

这个错误主要是由于Procfile配置错误造成的。

我遇到了同样的问题,这是我 Procfileweb: 之间的额外 space。 修复该应用程序后即可正常运行。

web: gunicorn djang_project_name.wsgi:application --log-file - --log-level debug
heroku ps:scale web=1
python manage.py migrate

这解决了我的问题。

我之前做过python manage.py collectstatic

的部分

对于首次通过 heroku 部署 Django 应用程序的用户,请确保在 Procfile 中提供正确的应用程序名称。我在第一次部署时犯了这个错误。

web: gunicorn appname.wsgi:application --log-file - --log-level debug
python manage.py collectstatic --noinput
manage.py migrate

此处“appname”是我的项目名称,其中存在 settings.py 文件。