Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30138ms.
- Spring Boot version 2 and above
- Java version 8 and above
- All HikariCP versions
Root cause –
HikariCP connection pool is not able connect with database. There can be many root causes for this.
If you are required to be connnected with VPN to access machine hosted database then timed out could occure.
If database has heavy load and not able to provide connection as requested by user. Default timeout in HikariCP is 30000 ms (30 seconds)
Check connection time out set for HikariCP connection pool.
If the values are set in code
HikariConfig config = new HikariConfig();
config.setConnectionTimeout(50000); // values are in milli seconds
If the values are set in
Important Note –
By increasing the timeout may solve the symptom but almost certainly does not address the root problem. Make sure you are analyzing it very well why old timeout is not enough to get new connection.
Do you have another solution?
The solution provided above is based on the scenario our one of the developers/contributors faced. If you faced the same issue and found any other root cause then please share your solution in the comment section below. We will add the solution in this article.