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

Spring Boot连接PostgreSQL报错HikariPool初始化异常求助

排查Spring Boot连接PostgreSQL(端口5433)的EOFException问题

以下是针对你遇到的org.postgresql.util.PSQLException: The connection attempt failed(根源为java.io.EOFException)的具体排查方案:

  • 确认PostgreSQL服务是否监听5433端口
    执行对应系统的命令检查端口状态:

    # Linux/macOS
    netstat -tulpn | grep 5433
    # Windows
    netstat -ano | findstr :5433
    

    若无输出,说明PostgreSQL未在5433端口启动。需修改postgresql.conf中的port参数为5433,之后重启PostgreSQL服务。

  • 检查数据库连接配置的准确性
    确保application.properties或application.yml的配置无拼写错误:

    # 示例application.properties配置
    spring.datasource.url=jdbc:postgresql://localhost:5433/your_db_name
    spring.datasource.username=your_username
    spring.datasource.password=your_password
    spring.datasource.driver-class-name=org.postgresql.Driver
    

    重点核对:端口号是否为5433、数据库名称是否存在、用户名密码是否正确,避免localhost与127.0.0.1的解析差异导致的问题。

  • 验证PostgreSQL的连接权限配置
    修改pg_hba.conf,添加允许本地连接5433端口的规则:

    host    all             all             127.0.0.1/32            scram-sha-256
    

    注意规则的加密方式需与postgresql.conf中password_encryption的配置匹配,修改后重启PostgreSQL。

  • 排查防火墙或安全软件的拦截
    本地防火墙、杀毒软件可能会拦截5433端口的连接请求,可临时关闭防火墙测试,或手动添加5433端口的入站/出站允许规则。

  • 核对PostgreSQL驱动与Spring Boot的兼容性
    确保依赖中的驱动版本适配Spring Boot版本:

    <!-- Maven示例,适配Spring Boot 2.x/3.x -->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    

    避免使用过低版本的驱动(如低于42.2.0)引发协议兼容问题。


内容的提问来源于stack exchange,提问作者iboukou blessing ogoudele

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 23:49:58