gpt4 book ai didi

Django 1.3.1 Heroku Postgres 错误

转载 作者:行者123 更新时间:2023-11-29 12:47:19 25 4
gpt4 key购买 nike

我们最近将我们的网站推到了暂存状态,从那以后一直在努力让它恢复正常,而 Heroku 的团队并没有真正及时做出回应,所以我转向社区看看是否有快速修复。

我们废弃了旧的并设置了一个仍然存在相同问题的新堆栈

heroku config
DISABLE_INJECTION: 1

settings.py

import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USER': 'myuser',
'PASSWORD': 'mypassword',
'PORT': '',
'HOST': 'localhost'
},
}

这是完整的轨迹。

heroku run python myapp/manage.py syncdb

Traceback (most recent call last):
File "fundedbyme/manage.py", line 11, in <module>
execute_manager(settings)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, 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 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 90, in handle_noargs
syncdb.Command().execute(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 56, in handle_noargs
cursor = connection.cursor()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 252, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 140, 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: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?

最佳答案

DATABASES = {
'default': dj_database_url.config(default=os.environ.get('DATABASE_URL'))
}

关于Django 1.3.1 Heroku Postgres 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13064782/

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