You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache Arrow Flight SQL Driver连接PostgreSQL认证失败及端口配置问题

问题解决指南:Apache Arrow Flight SQL 连接 PostgreSQL 认证错误与监听IP调整

一、初始认证错误的原因与修复

你遇到的transport: authentication handshake failed: EOF错误,核心原因是连接端口错误:

  • 常规PostgreSQL服务默认监听5432端口,但Arrow Flight SQL插件是独立运行的服务,默认监听15432端口。
  • 你的Flight SQL连接代码误用了5432端口,相当于直接连接PostgreSQL原生服务而非Flight SQL服务,导致握手失败。

修复后的连接代码:

import adbc_driver_flightsql.dbapi
import adbc_driver_manager

# 注意端口改为Flight SQL默认的15432
conn = adbc_driver_flightsql.dbapi.connect('flightsql://username:password@172.20.30.40:15432/database')

with conn.cursor() as cur:
    cur.execute("SELECT 1")
    assert cur.fetchone() == (1,)
conn.close()

二、调整Arrow Flight SQL的监听IP

根据你的更新,Flight SQL仅监听127.0.0.1导致外部连接被拒,可通过以下步骤修改配置:

  1. 打开PostgreSQL配置文件postgresql.conf(通常路径为/etc/postgresql/<你的PG版本号>/main/postgresql.conf)
  2. 添加或修改arrow_flight_sql.listen_addresses参数,设置允许监听的IP:
    • 若要监听所有IP,配置为:
      arrow_flight_sql.listen_addresses = '*'
      
    • 若要指定特定IP(比如服务器内网IP+本地回环),配置为:
      arrow_flight_sql.listen_addresses = '172.20.30.40,127.0.0.1'
      
  3. 重启PostgreSQL服务使配置生效:
    sudo systemctl restart postgresql
    
  4. 验证监听状态:
    ss -tulpn | grep arrow_flight_sql
    

额外注意事项

  • 确保服务器防火墙开放15432端口,允许客户端IP访问
  • 检查pg_hba.conf是否允许对应IP的连接请求(Flight SQL使用的认证逻辑与PostgreSQL原生一致,可参考现有授权规则添加适配条目)

内容的提问来源于stack exchange,提问作者usdn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 18:43:12