因本地資源有限,在公共測試環境搭建了PGsql環境,從數據庫本地localhost訪問正常,在相同網段的遠程機器訪問報如下錯誤
“server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request”
檢查pg日志,報錯日志為FATAL: no pg_hba.conf entry for host "XX.XX.XX.XX",經查閱,這條錯誤的原因是因為客戶端遠程訪問postgresql受限所致,因為postgresql默認情況下除本機外的機器是不能連接的。修改pg_hba.conf與postgresql.conf兩個配置文件即可解決。
修改方式請參考https://blog.csdn.net/liuchunming033/article/details/44810899
參考文檔地址:
程序鏈接PostgreSQL 時報錯"no pg_hba.conf entry" - CSDN博客
https://blog.csdn.net/liuchunming033/article/details/44810899