Health checks and probes for HAPI FHIR containers

Health checks tell Docker, Kubernetes and load balancers when a HAPI FHIR server is ready for traffic and when it needs a restart. Getting the probe split and startup timing right prevents restart loops during schema migration.

On this page

How HAPI FHIR health checks and probes keep containers from restart loops

A HAPI FHIR JPA starter container can restart over and over, or receive traffic before it can answer FHIR requests, when the platform checks its health too early or too strictly. Health checks and probes tell the container runtime whether the server process is alive and whether it is ready to serve. Configure them whenever the server runs under Docker, Docker Compose or Kubernetes, and set them deliberately before go-live, because a server that is still applying its database schema looks broken to a probe that expects an immediate answer. The starter is a Spring Boot application, so the status the probes read comes from the Spring Boot actuator health endpoint, which reports the state of the application and its dependencies such as the database.

The deployment options only determine where the probes get wired. The published hapiproject/hapi image, a Compose file, and the Helm chart each have their own place to declare a health check or probe, and each needs the same underlying endpoint. The exact endpoint paths, the management port, and which health details are exposed depend on the starter version in use, so confirm them against that version's configuration before writing any probe. Check the JDK requirement too: HAPI FHIR 8.2.0 requires JDK 17, and a mismatched Java runtime can fail at startup in a way that looks like a probe failure. Confirm the version and runtime together before you tune any timeout.

Set the probes with the startup phase in mind. Liveness should answer whether the process is stuck, and it should not fail while the server is still migrating the database schema on first start or after an upgrade. Readiness should answer whether the server can take FHIR traffic, so a pod stays out of the load balancer until the database connection and migrations are complete. Use a startup probe or a generous initial delay for slow first boots, and measure how long your own database migration takes in a test environment before choosing values. Review the failure threshold and period together, since an aggressive liveness probe is the most common cause of a restart loop, and confirm the rules with your platform team and your database owner.

Liveness, readiness and startup: which probe answers which question

A Docker HEALTHCHECK instruction runs a command inside the container at a set interval and records the result as the container's health state. Docker does not restart an unhealthy container by itself. The status is visible through docker ps and docker inspect, and orchestration tools or your own scripts decide what to do with it. On a single host, that makes the health check a signal for operators and monitoring rather than an automatic recovery mechanism, unless a restart policy or external watchdog acts on it.

  • Failure effect: the container is marked unhealthy. Nothing is restarted or removed from a load balancer unless you add that behavior.
  • Check target: point the check at a lightweight endpoint, such as the actuator health path, and confirm the path and port in your image version.
  • Timing values: interval, timeout, retries and start period control how long a slow boot is tolerated before the state flips. Set the start period to cover schema migration.
  • Dependency checks: a database check here will mark the container unhealthy during a database outage, which is useful for alerting but should not be the only signal.
  • Health groups: confirm which health groups the starter exposes in your version and which one the image's own tooling expects.

Before go-live, trigger a database outage in a test environment and confirm that the container state, alerts and any restart automation react the way your runbook says.

How to wire actuator health into Docker and Kubernetes

This sequence takes the HAPI FHIR JPA starter from a running server to a container that Docker and Kubernetes can judge correctly, with liveness and readiness separated so a slow schema migration does not get the pod restarted. Each step ends with a check you can run before moving on.

  1. Confirm the health endpoint answers on the server port

    Start the JPA server with its database reachable and call the Spring Boot actuator health path on the same port that serves FHIR requests. Your platform team or the person running the server does this from inside the network the containers will use, not only from a laptop. Check that the response is HTTP 200 with a JSON body whose status field reads UP. If the path returns 404, confirm that the actuator is on the classpath and that the health endpoint is exposed in your application configuration, because the starter's defaults can differ between versions. Confirm the exact path against the version you deploy.

  2. Decide which health groups feed each probe

    Spring Boot separates health into groups, so you choose what liveness and readiness each mean before you write any probe. Liveness should answer whether the process is stuck and should not depend on the database, because a database outage restarted in a loop helps nobody. Readiness should answer whether the server can serve FHIR traffic, which normally includes the database connection and any schema check. Write this decision down with the team that owns the server, including what happens when a downstream system such as a terminology load is unavailable. The output is a short table mapping each probe to the health components it includes.

  3. Add the container health check

    Add a HEALTHCHECK instruction to the image or a healthcheck block in Docker Compose that calls the actuator path with curl or wget, depending on what the image provides. Set an interval, timeout and retry count that suit your environment, and confirm that the chosen tool exists in the image tag you run, since minimal distroless images may not include a shell or curl. Start the stack, then run docker inspect on the container and read the Health.Status field. It should move from starting to healthy once the server finishes booting. If it stays unhealthy, read the container logs before changing timeouts.

  4. Set Kubernetes liveness and readiness probes

    In the Helm values or the pod spec, define a livenessProbe and a readinessProbe, each with an httpGet path, the server port, an initial delay, a period and a failure threshold. Point liveness and readiness at the separate health groups chosen in the earlier step. Set the initial delay and failure threshold from your own measured startup time, not from a default, so that the window covers schema migration on a large database. Confirm the setting in the rendered manifest with helm template before applying it. The check is that the manifest contains both probes with the paths and ports you intended.

  5. Use a startup probe for slow schema migration

    When first boot runs schema migration against a large PostgreSQL or Microsoft SQL Server database, the server can take much longer to become ready than a steady-state restart. A startup probe holds liveness checks back until the server first responds, so the kubelet does not kill a pod that is still migrating. Ask your database team how long migration took in a test environment with a copy of production-sized data, and size the startup probe failure threshold to cover that time with margin. Confirm the value with a test run rather than estimating it.

  6. Verify the pod stays not ready during a slow start

    Deliberately slow the first boot, for example by pointing the server at a database that accepts connections but delays the migration, or by adding a short pause in a test-only configuration. Watch the pod with kubectl get pods -w and confirm that it shows 0/1 Ready while the server is still starting, and that it does not restart during that window. Run kubectl describe pod to confirm that the startup and readiness probes report failures and then success. The pod should show 1/1 Ready only after the migration has finished and the FHIR metadata endpoint responds.

  7. Test failure behavior and record the settings

    Break the database connection on a test pod and confirm that readiness fails and the pod is removed from the service endpoints, while liveness does not restart it unless the process itself is stuck. Restore the connection and confirm the pod returns to Ready. Record the final probe paths, ports, delays and thresholds, the health groups behind each probe, and the test results in your runbook, so that upgrades to the server version re-run the same checks. Ask your platform or support provider to confirm these settings against the exact image tag you deploy.

Handling slow startup during schema migration on PostgreSQL or SQL Server

The JPA server validates and migrates its database schema before it begins serving requests, so a first boot against an empty database, or a boot after a version upgrade that changes the schema, can take much longer than a normal restart. If the container's probes allow only a short window, the orchestrator may restart the pod during migration, and the restart can interrupt the schema work and leave the next attempt to start from a partial state. The fix is to size the startup allowance from a measured migration time, not from a guess. Run the first boot against a copy of production-sized data in a staging environment, time how long the container takes to answer its health endpoint, and record that figure for each HAPI FHIR version you plan to move through. Confirm the exact migration behavior for your target release in the HAPI FHIR upgrades notes before you set thresholds.

Three approaches are available, and each carries a different trade-off. A generous startupProbe keeps the container under one set of rules and tolerates a long first boot, but it also delays detection of a container that is genuinely stuck during startup. A longer initialDelaySeconds on the readiness or liveness probe is simpler, but it applies the delay to every restart, not only to migrations, so failures are noticed later in normal operation. Moving migration into a separate job, run once before the Deployment rolls out, keeps application pods fast to start and makes migration failures visible in the job logs, but it adds a pipeline step that must succeed in order and a process to ensure only one migrator runs at a time. Whichever you choose, keep liveness checks away from database-dependent logic so that a slow database does not trigger restarts.

Only PostgreSQL and Microsoft SQL Server are supported production databases for the JPA starter. MySQL is not supported, and the embedded H2 default is meant for evaluation, not production, so a cluster that starts on H2 will need a planned data move before go-live. Confirm your database version, connection pool limits and migration permissions with your DBA, because a migration that cannot create or alter tables will fail at the same point on every attempt. Record the migration time per environment, and review the JPA server introduction when you plan the database side of the rollout.

Common probe mistakes that cause outages

Most probe-related outages on HAPI FHIR containers come from a small set of mistakes: probes that check the wrong thing, probes that fire too early, and failures that are hidden from the people who need to see them. Each card below names one mistake, the symptom it produces and the fix to apply before go-live.

Readiness tied to external services

When the readiness probe calls a database, terminology service or other external dependency, one outage upstream marks every pod unready at the same moment. The Service then removes all endpoints, and clients see errors even though the FHIR server process is healthy. Check which components the readiness group includes, and keep dependency checks out of readiness unless a pod truly cannot serve requests without them.

Liveness restarts during migration

Schema migration on first start can run for a long time on a large database, and a liveness probe with a short initial delay or low failure threshold will kill the container mid-migration. The restart then begins the migration again, which can loop indefinitely. Use a startup probe with a generous failure budget so liveness only starts after the application is up, and confirm the migration duration in a staging run against a copy of production-sized data.

Probes on paths not exposed

A probe that points at a path the starter does not serve returns 404 on every attempt, which Kubernetes or Docker reads as failure. The pod never becomes ready even though the server runs correctly. Confirm the exact health endpoint the deployed version exposes, check it with a direct request from inside the container, and set the probe path to match before comparing probe behavior with the rest of the cluster.

Missing path rewrite at ingress

When the proxy or ingress serves the FHIR server under a context path, a probe sent to the pod on the root path may not match what the application expects, or the public health URL may route to the wrong backend. External monitors then report failures that the pod-level probe does not show. Verify the context path and the proxy rewrite rules together, and test the health URL through the same ingress that clients use.

Restart policy hides failures

A restart policy that brings a container back after each failed probe keeps the service running, but the restart count can grow quietly for days while the underlying fault repeats. Operators see a healthy-looking deployment until a crash loop exhausts capacity. Alert on restart counts and on readiness transitions, record the probe failure reason in logs, and review restart history as part of routine operations.

How probe results flow from the actuator to the scheduler

The flow starts at the HAPI FHIR container, where the Spring Boot actuator exposes health status that depends on the database and the schema migration step. Docker's HEALTHCHECK and Kubernetes probes poll that endpoint, and their results feed the load balancer or Service endpoint and the restart decision. Check that the startup probe allows enough time for migrations, and that a failing database marks the pod unready without triggering a restart loop.

Probe results move from the actuator to routing and restart decisions.

Security and exposure of health endpoints

A health endpoint is useful to orchestrators and monitors, but it can also tell an outsider what the server is and how it is built. The cards below cover what to restrict, where probe traffic should come from, and how failures are recorded. HAPI FHIR provides building blocks rather than a single security layer, so the operator must confirm which endpoints are reachable from outside the cluster.

What the health output reveals

Actuator health responses can include component names, database status, disk details and build information when detailed output is enabled. Each of these helps an attacker map the stack and time an attack around a known database or dependency. Check the response for an unauthenticated request from outside your network, and confirm that detailed sections only appear for callers you trust.

HAPI FHIR security docs

Limit detailed output to probes

Keep the public liveness and readiness responses minimal, returning only a status value. Expose richer component detail on a separate management port or behind an internal address that only the kubelet, monitoring agents and operators can reach. Confirm this in the rendered configuration, since a value set in one environment file can quietly override the other.

Keep management endpoints off ingress

Actuator management endpoints can expose metrics, environment values, loggers and other operational data that should never be routed through the public ingress. Review every ingress rule and path prefix that forwards to the server, and confirm that paths such as the management base path return nothing from the internet. Test this from outside the cluster after every chart or proxy change.

Network policy for probe traffic

Kubernetes probes come from the node's kubelet, and Docker health checks run inside the container, so a policy should allow only those sources to reach the management port. Deny ingress to that port from other namespaces and pods by default. Confirm your CNI actually enforces NetworkPolicy, because an unenforced policy looks correct on paper and protects nothing.

Authentication for the FHIR base

Health endpoints are separate from the FHIR API, and the AuthorizationInterceptor and other building blocks protect FHIR resources, not the probe path. Confirm which paths your deployment exposes without credentials, including the metadata and health paths. Anything reachable without credentials should be listed in your review and justified in writing.

Logging and alerting on probe failures

Probe failures are a signal of restart loops, database outages or slow migrations, so they should reach your logs and monitoring. Record the failing check, the timestamp and the response code, but keep probe requests out of audit trails for clinical data access. Ask who reviews these alerts and how long a failing probe is allowed to persist before someone acts.

Questions teams ask before configuring HAPI FHIR probes

How long does it take to set up health checks for a HAPI FHIR container?

The probe configuration itself is small, usually a few lines in the Dockerfile, Compose file or Helm values, so the time is driven by everything around it. The effort grows with how many environments you run, whether the JPA server starts a schema migration on boot, how long your database takes to respond on a cold start, and how many teams need to agree on what "ready" means. Confirm the starting state of your environments and your upgrade cadence before estimating. A written scope should list each environment, the probe types, the startup behavior you have tested, and the evidence you expect at handover.

Can our internal platform team set up HAPI FHIR probes without outside help?

In many organizations yes, provided the team already runs containers on Kubernetes or Docker and has access to the server's logs and actuator output. The work that usually needs a second look is startup timing during schema migration, a readiness check that depends on the database, and confirming that the actuator endpoints are not exposed publicly. DeployOpen can take on any part of this as a fixed-scope engagement, including a review of your existing manifests. Decide which parts your team owns after the first test run, not before.

What does the work need from our team, such as cluster access and database timings?

Expect to provide the following before work starts:

  • Access to a non-production cluster or Docker host where the HAPI FHIR image can run with the same database engine as production
  • The HAPI FHIR version you plan to run and the JDK level it requires, which the versions documentation lists per release
  • The database type. The JPA starter supports PostgreSQL and Microsoft SQL Server for production, and does not support MySQL
  • Observed migration and startup times from a representative database, measured with the schema you will actually deploy
  • The ingress or proxy path, so you know which endpoints are reachable from outside the cluster

Database sizing matters because a large existing schema can take longer to migrate than a fresh install.

Should the HAPI FHIR readiness probe check the database connection?

Usually yes, but with care. A readiness probe that checks the database lets the orchestrator stop routing traffic to an instance that cannot reach its data, which is the main reason to include it. The risk is a database outage or slow failover that marks every pod unready at once, which removes capacity exactly when it is needed. Keep liveness checks simple so a slow database does not trigger restarts, and set readiness thresholds from measured response times. Test both failure modes in staging: a database that is slow, and one that is unreachable.

How should probes handle an upgrade that runs schema migrations?

The safest approach is to give the first start a startup probe with a long enough failure window to cover the migration, so liveness checks do not kill the container while the schema is changing. Run the migration on a copy of production data before the upgrade window, record how long it took, and set the startup window with margin above that figure. Plan for rollback as well, since a migrated schema may not be compatible with the previous server version. Check the HAPI FHIR upgrade notes for each version step, and confirm with your database team how backups are taken before the migration begins.

What should a quote for HAPI FHIR probe work include?

A quote should follow from a written scope and list the items separately:

  • The environments covered and the deployment method (Docker image, Compose, or the Helm chart)
  • The probe design: which endpoints back liveness, readiness and startup checks, and how the database is involved
  • The migration test plan, including the copy of data used and the evidence captured
  • Documentation and a handover session for your operations team
  • Any retest after the first upgrade, and whether ongoing support is needed

Ask which items are one-time and which recur, such as retesting after each HAPI FHIR upgrade. DeployOpen does not publish a price list, so the quote is the source for cost.

Are actuator health endpoints safe to expose on a HAPI FHIR server?

Probes need the health endpoint reachable by the kubelet or Docker daemon, but that does not mean it should be reachable from the internet. Keep the management port separate from the FHIR API port where your configuration allows it, and block management paths at the proxy or ingress. Detailed health output can reveal dependency names and versions, so review what each endpoint returns before you publish it. Confirm the exact property names and defaults for your starter version in its documentation, since they change between releases.

What a scoped probe and startup review covers

A fixed-scope probe and startup review checks how the HAPI FHIR JPA server behaves from the moment its container starts until it is serving traffic, and then under routine restarts. The reviewer starts with what exists today: the Dockerfile or image tag in use, any Docker Compose service definitions, the Helm chart values and the Kubernetes Deployment, including the livenessProbe and readinessProbe blocks, the startupProbe if one is set, and any HEALTHCHECK instruction. Each probe is traced to the endpoint it calls, the port it uses and the timeouts and failure thresholds that decide when Kubernetes restarts a pod or removes it from service. The reviewer also confirms which Spring Boot actuator endpoints are exposed, because the health endpoint's detail level and its network exposure are settings the operator must choose and document.

The second part of the review measures the startup path. A HAPI FHIR JPA server that connects to PostgreSQL or Microsoft SQL Server may run schema creation or migration before it accepts requests, so the reviewer records how long a cold start takes against an empty database, a populated database and a database that needs a schema upgrade. Those timings, along with database connection pool settings and any database readiness dependency, decide the startup probe thresholds and whether the liveness probe could restart a pod in the middle of a migration. The engagement produces written probe configuration for each environment, a short runbook for slow starts and test evidence: logged startup durations, forced failover and restart results and probe event records. Scope, deliverables and timelines are agreed in writing before work starts, and this page does not give a price. The quote follows from the agreed scope, which should name the environments, the deployment method and the number of database states to test.

How DeployOpen scopes and supports HAPI FHIR deployments

DeployOpen plans, implements, hardens and documents self-hosted open-source platforms inside your own infrastructure. For health checks and probes on HAPI FHIR containers, we start from your startup behavior, database and orchestrator, then deliver probe configuration, tests and a runbook your team can operate after handover.

How we scope

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • We confirm the container image, tag, database and orchestrator in use for the HAPI FHIR server.
  • We agree how long schema migration and first start may take in your environment before setting probe thresholds.

How we build

  • We configure the actuator health endpoint and decide which checks belong in liveness and which in readiness.
  • We set Docker health checks or Kubernetes probes with startup probes for slow schema migration on first boot.
  • We test failure cases such as database outages, failed migrations and restarts under load before sign-off.

How we hand over

  • You receive probe configuration, health endpoint settings and the reasoning behind each threshold.
  • Documentation covers how to read health status, what triggers restarts and how to roll back a probe change.
  • We walk your platform and operations engineers through the runbook so they can run the setup without us.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Probe settings are reviewed when you change the HAPI FHIR version, the Java runtime or the database.
  • Retainer scope, response expectations and review cadence are confirmed in writing before a retainer starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.