Spring Boot fails on startup: HikariPool-1 exception during pool initialization
HikariPool-1 - Exception during pool initializationShort answer
HikariCP opens one connection when the pool starts, and the startup fails when that connection fails. The message is a wrapper: the real reason is in the Caused by lines below it. Check the JDBC URL and database host first, then the driver class, then how long the pool may wait.
Fix it fast
1Find out which cause you have
Scroll to the last Caused by line of the stack trace. That line, not the Hikari line, names the problem.
grep -n "Caused by" app.log | tail -52Match what you see, then jump to its fix
- 1
The cause mentions the host, port or a refused or timed-out connectionThe JDBC URL is missing or points at the wrong placeFix - 2
The cause says the driver was not found or no suitable driverThe driver cannot be resolved from the URLFix - 3
It works on a second start, or in Docker only on the first runThe app starts before the database accepts connectionsFix
- 1
What does the error look like?
HikariPool-1 - Exception during pool initializationCaused by: ... (the underlying driver exception)
Cause 1 of 3
The JDBC URL is missing or points at the wrong place
1Check
In Spring Boot you must set spring.datasource.url. Without it Boot tries to auto-configure an embedded database instead. Hikari throws a SQLException when no connection becomes available within connectionTimeout (30 seconds by default, minimum 250 ms).
grep -rn "datasource" src/main/resources/application*
nc -vz db-host 54322Fix
Set the URL, username and password for the database you really run.
spring.datasource.url=jdbc:postgresql://db-host:5432/app
spring.datasource.username=appuser
spring.datasource.password=${DB_PASSWORD}3Verify
Restart the application; the pool starts without the exception.
mvn spring-boot:runConfirmed by docs.spring.io
Cause 2 of 3
The driver cannot be resolved from the URL
1Check
HikariCP tries to resolve a driver through DriverManager from the jdbcUrl alone, and its docs say to set driverClassName only after an obvious driver-not-found error. Spring Boot deduces the driver from the URL for most databases.
mvn dependency:tree | grep -i "mysql\|postgresql"2Fix
Add the driver for your database to the build. Set spring.datasource.driver-class-name only if Boot cannot deduce it.
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>3Verify
Restart and check the first Hikari log line.
mvn spring-boot:runConfirmed by github.com
Cause 3 of 3
The app starts before the database accepts connections
1Check
By default (initializationFailTimeout = 1) HikariCP tries to obtain and validate a connection and fails startup if it cannot. A positive value makes it keep trying for that many milliseconds; a negative value skips the initial attempt and starts the pool immediately.
docker compose ps2Fix
Make the database ready first (a health check and depends_on condition). If you prefer to wait inside the app, give the pool a startup window.
spring.datasource.hikari.initialization-fail-timeout=600003Verify
Start both services together.
docker compose upConfirmed by github.com
How do I stop it coming back?
- Keep the datasource URL, user and password in environment variables per environment, not in the code.
- Use a health check so the app container waits for the database.
- Read the last Caused by line first; fix that, not the Hikari line.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Back end
Spring Boot cannot create the HikariDataSource: no suitable driver class
Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
Spring Boot builds the pool from spring.datasource.url and deduces the JDBC driver from it.
3 causes, each with a fixDatabases
JDBC cannot talk to MySQL: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
Communications link failure means the TCP link to MySQL could not be opened or was closed.
3 causes, each with a fixDatabases
Spring Boot does not create the schema on MySQL or PostgreSQL
No CREATE TABLE statements from Hibernate appear at startup
Spring Boot only defaults ddl-auto to create-drop for an embedded database with no Flyway or Liquibase.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Flyway cannot handle the PostgreSQL URL after upgrading to Flyway 10 or newer
No database found to handle jdbc:postgresql://localhost:5432/app
Since Flyway 10, each database has its own module.
4 causes, each with a fix