A health check in Spring Boot is an endpoint that reports whether an application, and the things it depends on such as the database, disk and message broker, can serve traffic. Spring Boot Actuator provides it at /actuator/health, returning a status such as UP or DOWN that load balancers, orchestrators like Kubernetes and monitoring tools can poll.
Since Spring Boot 2.3 the health endpoint also exposes liveness and readiness probes, so you can tell an orchestrator the difference between "restart me" and "stop sending me traffic for now". The examples below target Spring Boot 3.x.
Add the Actuator starter to your build:
Start the application and call the endpoint:
By default only health is exposed over HTTP, and it shows just the aggregate status. This is deliberate: component details can leak information about your infrastructure.
To see which component is up or down, change the show-details and show-components properties:
Value of show-details | Behaviour |
|---|---|
never | Details are never shown (default) |
when-authorized | Details are shown only to users with the configured roles |
always | Details are shown to everyone |
Use when-authorized in production and restrict the roles with management.endpoint.health.roles. A response with details looks like this:
Actuator auto-configures a HealthIndicator for each technology it finds on the classpath and in the context. Common ones include db (a DataSource), diskSpace, ping, redis, mongo, rabbit, mail and elasticsearch. The overall status is the worst status among all indicators, using the default order DOWN, OUT_OF_SERVICE, UP, UNKNOWN.
You can switch an indicator off when it is not relevant, for example:
Implement HealthIndicator and register it as a bean. The bean name minus the HealthIndicator suffix becomes the component name, so the class below appears as paymentGateway.
Keep indicators fast and bounded by a timeout. Health endpoints are polled often, and a slow check can make the whole probe time out and cause needless restarts.
Spring Boot detects Kubernetes automatically and enables the probe groups. You can also enable them anywhere:
This adds two endpoints:
| Endpoint | Meaning | Kubernetes use |
|---|---|---|
/actuator/health/liveness | The application is running and not in a broken, unrecoverable state | livenessProbe: restart the container if it fails |
/actuator/health/readiness | The application is ready to accept traffic | readinessProbe: remove from the Service if it fails |
Do not put external dependencies such as the database into the liveness group. If the database goes down, restarting every pod does not help and makes the outage worse. Readiness is the right place for dependency checks.
You can define your own groups to choose which indicators belong to which probe:
Expose the management endpoints on a separate port with management.server.port when you do not want them reachable from the public network, and protect any detailed output with Spring Security.
It is /actuator/health, available once spring-boot-starter-actuator is on the classpath. Change the base path with management.endpoints.web.base-path.
Details are hidden by default. Set management.endpoint.health.show-details to when-authorized or always.
Liveness says whether the process should be restarted. Readiness says whether it should receive traffic right now, for example while it is warming up or when a dependency is unavailable.
Yes. Implement HealthIndicator (or ReactiveHealthIndicator for WebFlux) and expose it as a bean.
Spring Boot health checks come from Actuator and aggregate HealthIndicator beans into one status at /actuator/health. Show details only to authorised users, write fast custom indicators for your own dependencies, and use the liveness and readiness probe groups for Kubernetes, keeping external dependencies out of liveness.