我正在使用 pgAdmin4
并开发 node.js
应用程序。
我的计算机突然关闭,无法再连接到 postgresql
服务器。
尝试连接时出现的错误是:
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?
我尝试按照 this SO answer 中的建议运行 postgres -D/usr/local/var/postgres/
.
但是它给了我以下错误:
postgres: could not access directory "usr/loval/var/postgres": No such file or directory
Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
所以我只是手动删除了 PostgreSQL/.../data
文件夹中的 postmaster.pid
文件。
但是我仍然无法连接到数据库服务器。
我已经检查了 postgresql.conf
文件,并且
监听地址已设置为 listen_addresses = '*'
,端口设置为 5432
。
我还尝试删除 AppData/Roaming 文件夹中的 pgAdmin 文件。
但它给了我一个错误:
The application server could not be contacted
然后又出现了无法连接到服务器的相同问题。
最佳答案
有趣的是,只需删除AppData/Roaming文件夹中的pdAdmin文件,然后重新启动计算机并重新启动pgAdmin4即可。这为我解决了。
关于PostgreSQL服务器连接错误: could not connect to server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56242237/