在执行以下命令时,会遇到主题中的错误。
heroku run python manage.py db upgradeconn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?该应用程序在本地服务器上运行良好,但不能通过postgres db迁移到heroku。
已经尝试了无数的解决方案,但都还没有奏效。
启动数据库时,以下是弹出的消息
aiting for server to start....2020-10-11 20:14:58.637 +04 [11244] LOG: starting PostgreSQL 13.0 on x86_64-apple-darwin19.4.0, compiled by Apple clang version 11.0.0 (clang-1100.0.33.8), 64-bit
2020-10-11 20:14:58.641 +04 [11244] LOG: listening on IPv6 address "::1", port 5432
2020-10-11 20:14:58.641 +04 [11244] LOG: listening on IPv4 address "127.0.0.1", port 5432
2020-10-11 20:14:58.644 +04 [11244] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-10-11 20:14:58.672 +04 [11246] LOG: database system was interrupted; last known up at 2020-10-11 20:11:13 +04
2020-10-11 20:14:59.020 +04 [11246] LOG: database system was not properly shut down; automatic recovery in progress
2020-10-11 20:14:59.034 +04 [11246] LOG: redo starts at 0/1671320
2020-10-11 20:14:59.034 +04 [11246] LOG: invalid record length at 0/1671358: wanted 24, got 0
2020-10-11 20:14:59.034 +04 [11246] LOG: redo done at 0/1671320
2020-10-11 20:14:59.067 +04 [11244] LOG: database system is ready to accept connections
done
server started发布于 2021-03-28 19:52:01
您只需要重新启动服务器的psql。请小心使用此数据库:
sudo service postgresql restart我突然也犯了同样的错误。它会解决的。它与related copg2.connect(Dsn)无关
发布于 2020-10-12 00:52:42
问题是来自错误'"/var/run/postgresql/.s.PGSQL.5432"?",而不是来自日志“监听Unix套接字"/tmp/.s.PGSQL.5432”。首先,我会尝试将您的DSN更改为使用host=,这样您就不会尝试连接到套接字。然后,您需要弄清楚为什么psycopg2要寻找不同的套接字。通常,在一个发行版上对libpq进行编译/使用时会发生这种情况,该发行版将套接字放在/var/run/上,然后在套接字位于/tmp/的另一个发行版上运行。
https://stackoverflow.com/questions/64306451
复制相似问题