Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What do /actuator/health/liveness and /actuator/health/readiness mean, and how are they enabled?

/actuator/health/liveness reports whether the application is in a working internal state; if it fails, the platform should restart it. /actuator/health/readiness reports whether the application can accept traffic right now; if it fails, the platform should stop sending it requests. Spring Boot enables both automatically when it detects Kubernetes, or when we set management.endpoint.health.probes.enabled=true, and it updates them itself: readiness becomes ACCEPTING_TRAFFIC after the runners finish and REFUSING_TRAFFIC when shutdown begins.

Why this question is asked

Almost every Spring Boot service today runs on Kubernetes or a similar platform, and the platform decides when to restart our application and when to send it traffic based on these two endpoints. Getting them wrong causes real incidents: pods restarted in a loop, or requests sent to an application that is still warming up. Interviewers ask this question to see whether we know the difference between the two states and what Spring Boot does for us. In this answer, we will recap what probes are, look at what each endpoint means, see how to enable them, and follow how Boot changes the states during startup and shutdown.

1A Quick Recap of Probes

A probe is a check that the platform runs against our application at regular intervals. In Kubernetes, the kubelet, the agent that runs containers on each node, calls an HTTP path every few seconds and looks at the status code. A status between 200 and 399 counts as success; anything else, or a timeout, counts as failure.

Kubernetes has two main kinds of probes, and they lead to different actions. When a liveness probe fails several times in a row, the kubelet kills the container and starts a new one. When a readiness probe fails, the kubelet does not restart anything. It marks the pod as not ready, and the pod is removed from the Service's endpoints, the list of pod addresses that receive traffic. When readiness passes again, the pod is added back. Spring Boot gives each of these questions its own endpoint.

2What Liveness and Readiness Mean in Spring Boot

Spring Boot models these questions as availability states. LivenessState has two values: CORRECT means the internal state is fine, and BROKEN means the application has reached a state it cannot recover from, so a restart is the right answer. ReadinessState also has two values: ACCEPTING_TRAFFIC means the application is ready for requests, and REFUSING_TRAFFIC means it should not receive them for now, for example because it is still starting or already shutting down.

The endpoints translate these states into health statuses. /actuator/health/liveness reports UP when liveness is CORRECT and DOWN when it is BROKEN. /actuator/health/readiness reports UP when readiness is ACCEPTING_TRAFFIC and OUT_OF_SERVICE when it is REFUSING_TRAFFIC. Both DOWN and OUT_OF_SERVICE map to HTTP 503 by default, which the probe counts as a failure.

Notice what liveness deliberately does not include: the database, the message broker or any other external system. If the database is down, restarting our application does not bring it back; it only adds a restart storm on top of the database problem. Liveness is about the application itself.

Liveness and readiness side by side
LivenessReadiness
QuestionIs the internal state working?Can it take traffic now?
Spring stateCORRECT or BROKENACCEPTING_TRAFFIC or REFUSING_TRAFFIC
Health statusUP or DOWNUP or OUT_OF_SERVICE
HTTP code on failure503503
Kubernetes actionRestart the containerRemove pod from Service endpoints
External systemsNeverOnly ones this pod truly needs

3Enabling the Probe Endpoints

We usually do not have to do anything. Spring Boot detects that it runs on Kubernetes by looking for the environment variables Kubernetes sets in every container, such as KUBERNETES_SERVICE_HOST, and then turns the probe groups on. Outside Kubernetes, for example on a laptop or in a test, we switch them on with one property.

Properties
# application.properties
management.endpoint.health.probes.enabled=true
# Then:
# GET /actuator/health/liveness -> 200 {"status":"UP"}
# GET /actuator/health/readiness -> 200 {"status":"UP"}
# Optional: also serve them on the main port as /livez and /readyz
management.endpoint.health.probes.add-additional-paths=true

When probes are enabled, Boot creates two health groups named liveness and readiness. A health group is a named subset of health indicators, the components that each report one aspect of health. By default the liveness group contains the livenessState indicator and the readiness group contains the readinessState indicator, and nothing else. We can add indicators to readiness, for example with management.endpoint.health.group.readiness.include=readinessState,db, but we should do it with care for the reason we saw above.

The Kubernetes side then points at these paths. The paths below assume Actuator runs on the same port as the application; if we moved Actuator to a separate management port, the probes must point there instead.

4The Matching Kubernetes Configuration

Here is a minimal container definition that uses both endpoints. The numbers are typical starting values, not rules.

YAML
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
periodSeconds: 10
failureThreshold: 3 # restart after about 30 s of failure
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
periodSeconds: 5
failureThreshold: 2 # out of rotation after about 10 s

Notice that readiness is checked more often and gives up sooner. Taking a pod out of rotation is cheap and reversible, while a restart throws away the JVM, its caches and its warm-up work, so liveness should be slower to act.

5How Boot Changes the States During Startup and Shutdown

The useful part is that Boot moves these states at the right moments in the application lifecycle, so we get correct behaviour without code. As soon as the application context has been refreshed, Boot publishes LivenessState.CORRECT. At that point the beans exist and the web server is running, but the application may still have work to do in its ApplicationRunner and CommandLineRunner beans, such as loading a cache. Only after all runners have finished does Boot publish ReadinessState.ACCEPTING_TRAFFIC. So Kubernetes will not send requests while a runner is still preparing data.

On shutdown it works in reverse. When the context starts closing, for example because Kubernetes sent SIGTERM, Boot publishes ReadinessState.REFUSING_TRAFFIC, so the readiness probe starts failing and the pod is taken out of rotation while it finishes its in-flight requests. Combined with server.shutdown=graceful, which is the default in recent Boot versions, this gives a clean drain.

Step throughAvailability states over the application's life
  1. Context refresh startsreadiness not yet accepting
  2. Context refreshed, web server upLivenessState.CORRECT
  3. ApplicationRunner and CommandLineRunner beans runstill refusing traffic
  4. All runners finishedReadinessState.ACCEPTING_TRAFFIC
  5. SIGTERM, context begins closingReadinessState.REFUSING_TRAFFIC
  6. In-flight requests finish, JVM exits

6 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Should I add a startup probe as well?

Yes, if the application can take a long time to start. A startup probe, usually pointed at the liveness path with a large failureThreshold, tells Kubernetes to wait before running liveness at all. That lets a slow start take two minutes without loosening the liveness settings that apply once the application is running.

Can my own code change these states?

Yes. Any bean can publish an AvailabilityChangeEvent, for example AvailabilityChangeEvent.publish(context, ReadinessState.REFUSING_TRAFFIC) before a long maintenance task, or LivenessState.BROKEN when it detects an unrecoverable internal error. Code can also read the current states by injecting ApplicationAvailability.

Why do the probes return 503 and not 500?

Spring Boot maps DOWN and OUT_OF_SERVICE to 503 Service Unavailable by default, which describes the situation well: the service is temporarily not able to serve. The mapping can be changed with management.endpoint.health.status.http-mapping properties, but Kubernetes only needs any code outside 200 to 399.

7Conclusion

In this answer, we saw that liveness answers whether the application's internal state is working, so its failure leads to a restart, while readiness answers whether it can take traffic, so its failure only removes the pod from load balancing. Boot enables both on Kubernetes automatically, or with management.endpoint.health.probes.enabled=true, and it manages them for us: liveness becomes CORRECT after the context refreshes, readiness becomes ACCEPTING_TRAFFIC after the runners finish, and readiness turns to REFUSING_TRAFFIC as soon as shutdown begins.

What to say in the interviewAbout 70 seconds aloud

Open with

Liveness and readiness are two different questions the platform asks. Liveness asks whether the application is in a working internal state. If /actuator/health/liveness fails, Kubernetes restarts the container, so it should only fail for things a restart fixes, and never because of the database or another external system.

Then, if they want more

Readiness asks whether the application can accept traffic right now. If /actuator/health/readiness fails, Kubernetes just removes the pod from the Service endpoints until it passes again. Spring Boot exposes these as the liveness and readiness health groups. It turns them on automatically when it detects Kubernetes through the environment variables, and anywhere else I can set management.endpoint.health.probes.enabled to true.

Boot also drives the states for me. After the context is refreshed it sets liveness to CORRECT, then it runs the ApplicationRunner and CommandLineRunner beans, and only when they are finished does readiness become ACCEPTING_TRAFFIC. When shutdown starts, readiness goes to REFUSING_TRAFFIC so the pod is drained before it stops.

With add-additional-paths I can also serve them on the main port as /livez and /readyz.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference, Actuator
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What do /actuator/health/liveness and /actuator/health/readiness mean, and how are they...": https://scrivio-interview-library.netlify.app/spring-boot/actuator/b33c4639c5/