15

我试图在heroku中部署我的应用程序,但是当我最终尝试在heroku中运行我的应用程序时,我在浏览器中看到了这个:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

当我看到我的日志时,我得到下一个:

2013-08-31T19:53:30.672416+00:00 heroku[api]: Enable Logplex by user@example.com
2013-08-31T19:53:30.700218+00:00 heroku[api]: Release v2 created by user@example.com
2013-08-31T19:58:41+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:04:12.967456+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:04:13.161016+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:13:46+00:00 heroku[slug-compiler]: Slug compilation timed out: 904.285527871 seconds.
2013-08-31T20:22:52.646361+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:22:55.043424+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:26:14+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:38:41+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:41:22+00:00 heroku[slug-compiler]: Slug compilation timed out: 908.241350492 seconds.
2013-08-31T20:49:24.238496+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:49:24.644910+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:53:47+00:00 heroku[slug-compiler]: Slug compilation timed out: 907.148099965 seconds.
2013-08-31T20:56:59+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:58:50.641624+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_AQUA resource by user@example.com
2013-08-31T20:58:50.658435+00:00 heroku[api]: Release v3 created by user@example.com
2013-08-31T20:58:50.742803+00:00 heroku[api]: Add DATABASE_URL config by user@example.com
2013-08-31T20:58:50.782484+00:00 heroku[api]: Release v4 created by user@example.com
2013-08-31T20:58:50.840509+00:00 heroku[api]: Deploy 78dba6c by user@example.com
2013-08-31T20:58:50.852187+00:00 heroku[api]: Release v5 created by user@example.com
2013-08-31T20:58:54+00:00 heroku[slug-compiler]: Slug compilation finished
2013-08-31T21:00:25.085053+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:00:24.751074+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:01:03.272614+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:01:03.815558+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:02:10.279054+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:03:25.381362+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:03:25.709121+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:03:45.285962+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
christian@christian-R480-R431-R481:~/Documentos/heroku/portafolio/venv$ 
4

10 回答 10

29

Benjamin Manns 的解决方案对我有用,尽管我还需要一个额外的步骤。

据此,在推送Procfile解决方案后,运行以下命令:

heroku ps:scale web=1

网站现在应该正确加载。

有关推送到 heroku git repo 的更多帮助,请参阅

于 2014-03-30T17:04:49.247 回答
13

添加proc文件并运行以下命令

$ heroku ps:scale web=1

于 2014-12-01T05:58:25.653 回答
8

您是否阅读过Heroku 指南以设置 Django 应用程序?你的 Procfile 是什么样的?

您的项目应该有一个名为的文件Procfile,其内容应类似于

web: gunicorn hellodjango.wsgi
于 2013-08-31T21:27:23.937 回答
4

您的Procfile必须如下所示(对于 python):

网页:python myApp.py 运行服务器 0.0.0.0:$PORT

于 2017-10-10T18:42:43.327 回答
2

如果你在 python/django

heroku logs --tail

如果您无法找到错误并修复然后尝试做,

首先运行看看它是否在herokus local工作

heroku local web

我的是在 Procfile 中指定 django wsgi.py 文件的路径

查看他们的示例https://github.com/heroku/python-getting-started

Procfile 看起来与此类似

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

如果未安装,您可能必须安装 gunicorn 并将其添加到 requirements.txt

然后Git添加并提交,然后推送到heroku

git push heroku master

然后扩展您的应用程序

heroku ps:scale web=1
于 2019-05-06T05:39:28.160 回答
1

我执行了以下步骤以使其正常工作。

1)我不得不将我的 Procfile 移动到最外面的文件夹。

2)然后我不得不将我的 Procfile 更改为

web: gunicorn projectname.projectname.wsgi

3) 同样在我的 wsgi 文件中,我必须将设置路径更改为

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.projectname.settings')

4)在我的 settings.py 文件中,我必须更改我的 ROOT_URLCONF

ROOT_URLCONF = 'projectname.projectname.urls'

5)在 urls.py 我不得不改变我的路径

from projectname.applicationname import urls as app_urls

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(app_urls)),
]

6)最后我做到了

git push heroku master
heroku ps:scale web=1

在进行所有这些更改之后,heroku 就像一个魅力一样工作。但它不能在 Windows 上本地工作,因为我在某处读到 Windows 没有 gunicorn。

当我在本地尝试时python projectname/manage.py runserver,它说

ModuleNotFoundError: No module named 'projectname.projectname'

所以为了在本地运行它,我必须恢复上面的所有步骤:P

于 2020-01-04T22:52:45.100 回答
0

我的情况有点不同。我已经解决了所有问题并在 Heroku 上部署了我的应用程序。我之前在 Heroku 上部署了 3 4 python 应用程序。根文件夹中有 Procfile 和 requirements.txt。

这一次,我几乎尝试了所有指南和 StackOverflow 的答案,但一无所获。然后在之后添加一个空格web:gunicorn它工作得很好。

以前我在使用web:gunicorn wsgi:app

我只是把web: gunicorn wsgi:app它改成了它就像一个魅力

于 2021-11-05T13:56:05.020 回答
0

我收到应用程序错误我检查了 heroku 日志 --tail ,在desc="No web processes running" 主要是由于 Procfile 而发生的,所以在 Procfile 中我忘记在“web:”之后留出空间

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

所以检查你的 Procfile {这个文件将在项目文件夹内的根文件夹中创建}

于 2020-09-21T12:02:28.670 回答
0

虽然已经说过,但请检查Procfile,runtime.txtrequirements.txt是否在最外层文件夹中。(这些文件将被放置在 的位置manage.py

于 2021-05-19T05:45:13.943 回答
0

就我而言,这是 dynos 配置错误,我的意思是,如果您不是高级会员,请查看 heroku dashbord 是否可用于您的应用程序的 dynos。如果您没有估计,您可以通过单击指标来检查。运行命令 $ heroku ps:scale web=1 将您的代码推送到 master 中。

于 2020-07-03T01:33:33.830 回答