Postgresql connection marked as broken - Hikari Postgresql connection marked as broken - Hikari

[Solved] Postgresql connection marked as broken – Hikari


In the world of Spring applications, efficient database connectivity is paramount for seamless data transactions. However, encountering warnings like “Postgresql connection marked as broken by Hikari” can be a common challenge. In this article, we’ll explore potential solutions to address this issue and ensure a smooth operation of your Spring application with PostgreSQL.

Understanding the Problem

The warning and subsequent exception indicate that a PostgreSQL connection is marked as broken due to a SQLSTATE(08006) error, leading to an I/O error during communication with the backend. This issue can be disruptive, often putting the database in recovery mode.

Solution Steps

Review HikariCP Configuration: The first step is to carefully review the HikariCP configuration in your Spring application. Ensure that the settings are aligned with the requirements of your database.

Set Connection Test Query: To enhance connection validation, set an appropriate connection-test-query in the HikariCP configuration.

For example:

spring: datasource: hikari: connection-test-query: SELECT 1 

This query ensures that connections are actively tested before use.

Adjust Timeout Settings: Fine-tune the timeout settings based on your application’s requirements. The following are sample settings that you can adjust according to your needs

codespring: datasource: hikari: connectionTimeout: 30000 validationTimeout: 3000 maxLifetime: 1800000 maximumPoolSize: 10

connectionTimeout: Sets the maximum time in milliseconds that the pool will wait for a connection.

validationTimeout: Defines the maximum time allowed for a connection to be validated.

maxLifetime: Specifies the maximum lifetime of a connection in milliseconds.

maximumPoolSize: Sets the maximum number of connections in the pool.

Test and Iterate: After applying the changes, thoroughly test your Spring application to ensure that the connection issues are resolved. Monitor the application logs for any warning messages or exceptions.


Maintaining a robust connection between your Spring application and PostgreSQL is crucial for the overall performance and reliability of your system. By carefully configuring HikariCP settings, including connection test queries and timeout values, you can address the “Postgresql connection marked as broken by Hikari” issue and ensure a seamless data flow in your application.

Remember to tailor the configuration parameters to your specific application requirements, and regularly monitor and iterate on these settings as your application evolves. With these steps, you can enhance the stability of your Spring application’s database connections, providing a smoother experience for both users and developers.