PostgreSQL服务器连接错误: could not connect to server

标签 postgresql database-connection pgadmin pgadmin-4 postgresql-11

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

相关文章:

linux - 在 CentOS 8 中从 pgdg 存储库安装 postgresql12-server 后找不到 pg_ctl

GnuCOBOL 中的 PostgreSQL 游标重新打开错误

sql-server - 如何检查数据库是否存在?

c# - 将 DB Connection 对象传递给方法

postgresql - pgAdmin:作业选项不可见

postgresql - 如何在 Ubuntu 上使用 pgAdmin 将 Postgres 连接到本地主机服务器?

postgresql - 自米 :n Relation

python - OSError :/usr/lib/libgdal. so.20: undefined symbol :sqlite3_column_table_name

php - MySql 和 PHPMyAdmin 密码

python - Postgres 和 SqlAlchemy 没有正确更新行