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

Windows端pgAdmin连接Ubuntu 22.04的PostgreSQL-11.18遇超时错误求助

解决Windows pgAdmin连接Ubuntu PostgreSQL 11.18超时问题

1. 调整PostgreSQL监听配置

  • 找到PostgreSQL配置文件postgresql.conf(默认路径:/etc/postgresql/11/main/postgresql.conf),修改listen_addresses参数:
    listen_addresses = '*'
    
  • 重启PostgreSQL服务生效:
    sudo systemctl restart postgresql@11-main
    

2. 配置PostgreSQL访问权限

  • 打开同目录下的pg_hba.conf,添加允许Windows主机访问的规则(替换为你的Windows主机IP):
    host    all             all             你的Windows主机IP/32        scram-sha-256
    
    若要允许整个网段访问,可改为192.168.x.0/24这类格式,根据实际网络调整。
  • 再次重启PostgreSQL服务。

3. 开放Ubuntu防火墙端口

  • 允许PostgreSQL默认端口5432的入站流量:
    sudo ufw allow 5432/tcp
    sudo ufw reload
    
  • 验证规则是否生效:
    sudo ufw status
    

4. 测试网络连通性

  • 在Windows命令提示符中ping Ubuntu主机IP,确认网络可达:
    ping Ubuntu主机IP
    
  • 用telnet测试端口是否开放:
    telnet Ubuntu主机IP 5432
    
    若连接失败,优先排查网络链路或端口开放问题。

5. 核对pgAdmin连接参数

  • 确保pgAdmin中填写的主机地址是Ubuntu的真实IP(不能是localhost或127.0.0.1)。
  • 端口保持默认5432,用户名和密码需为PostgreSQL中已授权的合法账号。

内容的提问来源于stack exchange,提问作者Vinay Kumar Talreja

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 12:52:36