gpt4 book ai didi

sockets - Heroku postgres 连接 : "Is the server running locally and accepting connections on Unix domain socket"

转载 作者:行者123 更新时间:2023-12-04 23:48:29 25 4
gpt4 key购买 nike

我正在设置一个新的开发环境,按照 django 设置教程进行操作,但遇到了问题。这是我尝试运行 syncdb 时得到的结果

Running `python doccal/manage.py syncdb` attached to terminal... up, run.1
Traceback (most recent call last):
File "doccal/manage.py", line 14, in <module>
execute_manager(settings)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 459, in execute_manager
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.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/bas
e.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/com
mands/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/postgre
sql_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", lin
e 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: No such file or director
y
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

在使用相同的步骤之前,我已经设置了同一个项目,并且从未遇到过问题。几周前,我确实收到一封电子邮件,说 Heroku 正在从共享数据库中迁移出来,我认为这与某种方式有关。

此外,我确实注意到教程中有两个新步骤,即安装 dj-database-url 并将这些行添加到 settings.py

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

无论是否使用这些行,我都尝试过运行它,但无论如何都会遇到同样的问题。

另一篇帖子建议修复方法是这样做

heroku addons:add shared-database

尝试过,收到一条消息,指出共享数据库已弃用并使用 heroku-postgresql,但这没有效果。

感谢您的帮助

最佳答案

将主机配置为本地主机,如:

'HOST': 'localhost',

关于sockets - Heroku postgres 连接 : "Is the server running locally and accepting connections on Unix domain socket",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11974689/

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