我有一个新的 DigitalOcean Droplet,我在其中设置了一个 Postgres 数据库,我试图从我的本地机器(通过 pd.read_sql_query)访问该数据库。我一直无法与 Droplet 建立连接,而且我不知道我错在哪里。我已经更改了 pg_config 和 pg_hba 文件并重新启动了我的 psql 服务器。
这是我的 pg_hba 文件:
这是我的 pg_config:
这是我运行时 Droplet 上的输出
netstat -nlt
我的理论是,由于某种原因,端口 5432 仅侦听本地连接。作为参考,这里是 ls_pgclusters 的输出:
最后这是我尝试连接到服务器时得到的输出:
C:\WINDOWS\system32>psql -h xxx.xx.xxx.xxx -p 5432 -d dbName -U postgres
psql: error: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "xxx.xx.xxx.xxx" and accepting
TCP/IP connections on port 5432?
我不知道还有什么可以连接到服务器。任何帮助将不胜感激。
答案 0 :(得分:1)
你把listen_addresses
改成了*
,但是你忘记去掉行首的注释(#
),所以参数还是默认值{{1 }}。
删除 localhost
并重新启动 PostgreSQL。