PostgreSQL服务器连接错误:无法连接到服务器

问题描述 投票:0回答:2

我正在使用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?

我尝试按照postgres -D /usr/local/var/postgres/中的建议运行this SO answer。但是,它给了我以下错误:

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. 

所以我只是手动删除了postmaster.pid文件夹中的PostgreSQL/.../data文件。但是我仍然无法连接到数据库服务器。

我已经检查了postgresql.conf文件,并且监听地址已经设置为listen_addresses = '*',端口设置为5432

我还尝试删除AppData / Roaming文件夹中的pgAdmin文件。但这给了我一个错误:

The application server could not be contacted

然后出现无法连接到服务器的相同问题。

postgresql database-connection pgadmin pgadmin-4 postgresql-11
2个回答
0
投票

很有趣,只需删除AppData / Roaming文件夹中的pdAdmin文件,然后重新启动计算机并重新启动pgAdmin4。那为我解决了。


0
投票

在设置PostgreSQLPython/Django项目一起使用时遇到同样的挑战。阅读完resolved the issue here的官方文档后,我PostgreSQL-9.6.16

© www.soinside.com 2019 - 2024. All rights reserved.