gpt4 book ai didi

django - 推送到 Heroku 后为 "password authentication failed for user"

转载 作者:行者123 更新时间:2023-11-29 11:21:11 26 4
gpt4 key购买 nike

我关注了 heroku documentation安装一个 Django 应用程序,起初它运行良好。一天后,我将一些更改推送到服务器。在那之后,我根本无法访问该应用程序:FATAL: password authentication failed for user "drjstoymyqyarj"

我什至不能再同步数据库了:

$ heroku run python manage.py syncdb
Running `python manage.py syncdb` attached to terminal... up, run.1
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/app/.heroku/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: password authentication failed for user "drjstoymyqyarj"
FATAL: password authentication failed for user "drjstoymyqyarj"

我使用了 heroku 文档中推荐的数据库设置:

import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}

当我在将代码推送到服务器后检查日志时,有一个我之前没有注意到的可疑Process exited with status 143。也许这与它有关?

$ heroku logs
heroku[web.1]: State changed from up to starting
heroku[web.1]: Stopping all processes with SIGTERM
heroku[web.1]: Starting process with command `python ./manage.py runserver 0.0.0.0:41048 --noreload`
app[web.1]: Validating models...
app[web.1]:
app[web.1]: 0 errors found
app[web.1]: Django version 1.4, using settings 'ClosetList.settings'
app[web.1]: Development server is running at http://0.0.0.0:41048/
app[web.1]: Quit the server with CONTROL-C.
heroku[web.1]: Process exited with status 143
heroku[web.1]: State changed from starting to up

[编辑]
heroku pg:psql 相同的错误消息。但是,我可以使用 heroku run python manage.py shell 打开 Django shell,但我无法从其中访问任何数据(当然是同样的错误)。
[/Edit]

感谢任何帮助。

最佳答案

运行

heroku config

并查看是否配置了超过 2 个 heroku 数据库,并查看 DATABASE_URL 是否指向您配置的数据库。如果没有,那么您可以通过运行将您的数据库提升为默认的 DATABASE_URL:

heroku pg:promote HEROKU_POSTGRESQL_GREEN

HEROKU_POSTGRESQL_GREEN 是您的数据库名称,您将在配置中看到 HEROKU_POSTGRESQL_GREEN_URL。

将配置的数据库提升为默认数据库后,您就可以开始了。

关于django - 推送到 Heroku 后为 "password authentication failed for user",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11981280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com