[英]PostgreSQL server Connection error: could not connect to server
我正在使用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?
我嘗試按照此 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
以使用Python/Django
項目時遇到同樣的挑戰。
在閱讀了官方的PostgreSQL-9.6.16
文檔后,我在這里解決了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.