postgresql - 服务器是否在本地运行并接受 Unix 域套接字“/var/run/postgresql/.s.PGSQL.5432”上的连接?
问题描述
执行以下命令时遇到主题中的错误。
heroku run python manage.py db upgrade
conn = _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
解决方案
您只需要重新启动服务器的 psql。小心这个数据库:
sudo service postgresql restart
我突然遇到了同样的错误。它解决了。它与 psycopg2.connect(dsn) 无关
推荐阅读
- mysql - 我想根据另一列设置默认列值并添加 114 天
- ios - 打开操作表后如何删除 UIToolbar 下方的空白区域?
- triggers - 删除触发器导致删除集 Null 上的 FK 出现问题并导致 ORA-03113
- c++ - C++ 混淆宏
- javascript - 反应多重加载状态
- android - 用于 android 的 Ionic 4 硬件后退按钮在导航时无法在其他页面上运行
- python - 如何同时get.dummies和count
- nativescript - (Nativescript + Google Maps SDK)折线渐变颜色
- arrays - 值错误:使用序列(数组)设置数组元素
- html - 如何为下降线的部分着色?