0

我第一次使用 Procfileweb: python manage.py runserver '0.0.0.0:$PORT'成功启动,但在第一次git push它崩溃了这个错误:

OperationalError at /

could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?

重新启动 webrunner 没有帮助。有什么诀窍?heroku 日志输出:

2013-11-25T23:39:56.725138+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
2013-11-25T23:39:56.725138+00:00 app[web.1]:     conn = _connect(dsn, connection_factory=connection_factory, async=async)
2013-11-25T23:39:56.725138+00:00 app[web.1]: OperationalError: could not connect to server: Connection refused
2013-11-25T23:39:56.725138+00:00 app[web.1]:    Is the server running on host "127.0.0.1" and accepting
2013-11-25T23:39:56.725138+00:00 app[web.1]:    TCP/IP connections on port 5432?
2013-11-25T23:39:56.725138+00:00 app[web.1]:     return Database.connect(**conn_params)
2013-11-25T23:39:56.725138+00:00 app[web.1]: 
2013-11-25T23:39:56.872620+00:00 app[web.1]: [26/Nov/2013 00:39:56] "GET / HTTP/1.1" 500 118846

使用 gunicorn 它说找不到 gunicorn 应用程序和app[web.1]: bash: gunicorn: command not found and heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=shrouded-falls-4631.herokuapp.com fwd="188.163.187.182" dyno= connect= service= status=503 bytes=从 heroku 日志和heroku ps显示崩溃的应用程序 [web]。至少在第一次开始使用 djangos 的 runserver。但后来也摔倒了。

4

3 回答 3

0

感谢@user2707389,它实际上只适用于声明的所有应用程序,requirements.txt但我不明白为什么它没有-r选项。无论如何,修复进一步的 Procfile 和正确的 wsgi.py 使它活着。

于 2013-11-27T11:30:02.567 回答
0

您的数据库未连接。确保您设置了正确的DATABASE_URL环境变量,并且您实际上有一个激活的 postgres 计划。

于 2013-11-27T09:51:36.357 回答
0

我不知道确切的原因,但你为什么要在 heroku 上运行 django 的 runserver?Heroku 使用 gunicorn,它可以执行 project_name/project_name 文件夹中的 .wsgi 文件。

相反,请在 procfile 中使用:“web: gunicorn recipe.wsgi”,以便 gunicorn 为您的 django 应用程序提供服务。只是我的2美分。

此外,如果您使用 0.0.0.0:5432 或 127.0.0.1:5432,它似乎可以工作。

于 2013-11-26T00:31:22.010 回答