我正在使用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
然后出现无法连接到服务器的相同问题。
很有趣,只需删除AppData / Roaming文件夹中的pdAdmin文件,然后重新启动计算机并重新启动pgAdmin4。那为我解决了。
在设置PostgreSQL
与Python/Django
项目一起使用时遇到同样的挑战。阅读完resolved the issue here的官方文档后,我PostgreSQL-9.6.16
。