使用RPostgres连接PostgreSQL生产环境时遇意外断开错误求助
PostgreSQL生产环境连接失败排查求助
我使用DBI和pqdriver,通过RPostgres::Postgres()建立PostgreSQL连接,代码如下:
con <- DBI::dbConnect(RPostgres::Postgres(), dbname = "my_db", host = "10.10.10.194", port = 5432, user = "my_user", password = "my_password")
这套代码能正常连接UAT环境,但连接生产环境时失败(所有凭据均确认正确),报错信息如下:
Error: server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request.
目前已做的调试:telnet测试能成功通过,但用上述R代码连接就失败,不知道该怎么继续排查。
更新1
已咨询IT/数据库管理员,他们怀疑dbConnect是否通过代理访问,我不清楚如何验证这一点;另外我尝试用traceback()获取调用栈,截图内容如下:
调用栈层级依次为:RPostgres::Postgres() → DBI::dbConnect() → .local() → pq_driver_connect(),最终报错指向连接异常终止。
更新2
尝试用JDBC方式连接时,报错截图显示:
Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
内容的提问来源于stack exchange,提问作者info_seekeR
相关产品推荐
相关产品推荐

