![引导时出现“psycopg2.OperationalError:无法连接到服务器:连接被拒绝”错误](https://linux22.com/image/1116487/%E5%BC%95%E5%AF%BC%E6%97%B6%E5%87%BA%E7%8E%B0%E2%80%9Cpsycopg2.OperationalError%EF%BC%9A%E6%97%A0%E6%B3%95%E8%BF%9E%E6%8E%A5%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%9A%E8%BF%9E%E6%8E%A5%E8%A2%AB%E6%8B%92%E7%BB%9D%E2%80%9D%E9%94%99%E8%AF%AF.png)
成功导入 ssh 密钥对后,引导程序会生成此错误。
谁能帮我?
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
我努力了:
- 确保 PostgreSQL 已安装并正在运行:'sudo service postgresql start'
当我运行“sudo apt-get update”时出现此错误。
答案1
如果服务器正在运行但仍然收到错误,则必须将 Postgres 配置为接受来自其他 IP 的连接。为此,请找到该postgresql.conf
文件。
查找listen_addresses
属性并localhost
用逗号分隔的 IP 选择替换,或者*
接受来自任何 IP 的连接。
重新启动 postgresql 服务器。你应该没问题。:)
答案2
看起来 postgres 没有运行或者没有安装。
尝试:
sudo service postgresql start
答案3
运行之前,您必须检查是否已将文件放在正确的位置。例如。如果您正在使用 vagrant 和 virtual box,那么您必须将此文件保存在 vagrant 文件夹中。