Skip to content

Keycloak health and metrics endpoints

Get Keycloak’s health and metrics URLs on the management port, the options that turn them on, and ready-made Kubernetes probes, a Compose health check and a Prometheus scrape config.

Runs in your browser. Nothing you paste is sent to us.

Management interface

As seen from where you check it, such as the container or service name.

9000 by default (http-management-port).

Only if you move the endpoints under a path.

Configuration
KC_HEALTH_ENABLED=true
KC_METRICS_ENABLED=true

Endpoints

/health/started
http://keycloak:9000/health/startedup once the server has started
/health/ready
http://keycloak:9000/health/readyready for traffic, database reachable
/health/live
http://keycloak:9000/health/livethe process is alive
/health
http://keycloak:9000/healthall checks together
/metrics
http://keycloak:9000/metricsPrometheus format
Try it
curl -s http://keycloak:9000/health/ready
Container probes
startupProbe:
  httpGet:
    path: /health/started
    port: 9000
    scheme: HTTP
  periodSeconds: 5
  failureThreshold: 60
readinessProbe:
  httpGet:
    path: /health/ready
    port: 9000
    scheme: HTTP
  periodSeconds: 10
  failureThreshold: 3
livenessProbe:
  httpGet:
    path: /health/live
    port: 9000
    scheme: HTTP
  periodSeconds: 15
  failureThreshold: 4
Health and metrics are served on the management port, not on 8080 with the sign-in pages. Keep that port off the public address; reach it from inside the network.

How to use it

  1. Enter the host and management port, 9000 unless you changed it.
  2. Choose health checks, metrics and the extra metrics you want.
  3. Copy the options, then the probes or scrape config.
  4. Test with the curl command from inside the network.

What to know

Since Keycloak 25, health and metrics are served on a management interface of their own, port 9000 by default, apart from the sign-in pages on 8080. Turn them on with health-enabled and metrics-enabled.

/health/started, /health/ready and /health/live map onto Kubernetes startup, readiness and liveness probes. Readiness includes the database connection.

/metrics is in Prometheus format. HTTP histograms and per-realm user event counters add detail at the cost of more series.

Why health checks and metrics matter for Keycloak

When Keycloak is down, nobody signs in to anything. Health checks let the platform notice a broken instance and stop sending it traffic or restart it. Metrics let you see trouble coming: rising response times, memory pressure, failed logins, a database that slows down.

Both are built into Keycloak, but they are off by default and live on a port of their own. Teams that copy an older guide often look for them on the main HTTP port and find nothing. This tool gives you the right URLs, the options that turn them on, and ready-made probes and scrape settings.

The management interface in Keycloak 26

Since Keycloak 25, health and metrics are served on a separate management interface. It listens on port 9000 by default, apart from the sign-in pages and APIs on 8080 (or 8443 with HTTPS). Keeping them apart means you can expose sign-in to the internet while health and metrics stay inside your network.

OptionWhat it does
health-enabledTurns on the /health endpoints. A build option.
metrics-enabledTurns on /metrics. A build option.
http-management-portMoves the management interface off port 9000.
http-management-relative-pathServes the endpoints under a path, such as /management.
http-metrics-histograms-enabledAdds histograms for HTTP request durations.
event-metrics-user-enabledCounts user events per realm. Needs the user-event-metrics feature.

If Keycloak itself serves HTTPS, the management interface uses HTTPS too. Behind a proxy that ends TLS, with http-enabled=true, it answers plain HTTP.

Turn on health and metrics
KC_HEALTH_ENABLED=true
KC_METRICS_ENABLED=true
KC_HTTP_METRICS_HISTOGRAMS_ENABLED=true

They are build options

health-enabled and metrics-enabled are build options. A server started with plain start picks up a change on its own. A server started with start --optimized needs kc.sh build again, usually in the image’s Dockerfile.

The endpoints

PathAnswers 200 whenTypical use
/health/startedThe server has finished startingKubernetes startup probe
/health/readyThe server can take traffic, database includedReadiness probe, load balancer check
/health/liveThe process is aliveLiveness probe
/healthAll checks passA quick manual look
/metricsAlways, in Prometheus text formatPrometheus scraping

From inside the network you can try them with curl. The host below is a sample service name.

curl -s http://keycloak:9000/health/ready
curl -s http://keycloak:9000/metrics | head

Changing the port or path

Port 9000 is a common choice for other software too. If something else on the host or in the pod already uses it, move Keycloak’s management interface with http-management-port. Every probe, health check and scrape job must then use the new port.

You can also serve the endpoints under a path with http-management-relative-path, for example /management, which turns /health/ready into /management/health/ready. This helps when one monitoring proxy fronts several services. If you set http-relative-path for the main interface, set the management path explicitly too, so you know exactly where the endpoints live in your version. The tool adds the option whenever you enter a path.

A different port and path
KC_HTTP_MANAGEMENT_PORT=9100
KC_HTTP_MANAGEMENT_RELATIVE_PATH=/management
# then: curl http://keycloak:9100/management/health/ready

What this tool does and does not do

  • It builds the URL of every endpoint from the host, port, optional path and scheme you enter.
  • It writes the options for health, metrics, histograms, per-realm user event counters, a different port and a path, in any of the configuration formats.
  • It writes Kubernetes startup, readiness and liveness probes, a Docker Compose health check, and a Prometheus scrape config.
  • It does not call your server, so it cannot tell whether the endpoints answer. Try the curl command from inside your network.
  • It does not write alert rules or dashboards.

How to use it

  1. Enter the host as your monitoring sees it: a container name, a Kubernetes service, or a private address.
  2. Keep port 9000 unless you moved the management interface, and add a path only if you set one.
  3. Tick HTTPS if Keycloak serves HTTPS itself.
  4. Choose health checks, metrics, and the extra metrics you want.
  5. Copy the options into your deployment, then copy the probes, the Compose health check or the Prometheus job.
  6. Rebuild if you start with --optimized, restart, and test with the curl command.

Health checks in practice

Kubernetes probes

Use /health/started for the startup probe, with enough failures allowed to cover a slow first start. Use /health/ready for readiness, so a pod that loses its database stops getting traffic. Use /health/live for liveness, and keep it lenient: restarting a pod because the database is slow makes things worse.

Readiness probe
readinessProbe:
  httpGet:
    path: /health/ready
    port: 9000
  periodSeconds: 10
  failureThreshold: 3

The Keycloak Operator configures these probes for you. Write them yourself only when you deploy Keycloak with your own manifests or Helm chart.

Docker Compose

The official image has no curl or wget. The generated health check uses bash’s /dev/tcp to send a minimal HTTP request to /health/ready and checks for a 200 status line. Over HTTPS that trick does not work, so the tool falls back to checking that the port accepts connections.

Load balancers

A load balancer in the same network can check /health/ready on port 9000 directly. It does not need to go through the public address, and it should not.

Metrics in practice

/metrics returns Prometheus text format. It includes JVM metrics such as heap use and garbage collection, and HTTP server metrics. With histograms on, you can chart request latency percentiles. With user event metrics on, you can count logins and login errors per realm.

prometheus.yml
scrape_configs:
  - job_name: keycloak
    metrics_path: /metrics
    static_configs:
      - targets: ['keycloak:9000']

Histograms and per-realm counters add series. That is usually fine, but watch your Prometheus storage if you run many realms or many nodes.

Where it pays off

First production deploy

Turn on health from the start, so your platform can tell a starting node from a broken one. Add metrics before launch, not after the first incident.

Upgrading from an older version

Before Keycloak 25, health and metrics were served on the main HTTP port. After an upgrade, probes and scrape jobs that still point at 8080 fail. Move them to port 9000.

Moving from a VM to Kubernetes

On a VM you may have checked the sign-in page with an external monitor. In Kubernetes, use the three probes and scrape metrics from inside the cluster.

Common errors and how to fix them

/health returns 404

Either health-enabled is not set, or the request went to port 8080. Health is on the management port, 9000 by default. With --optimized, a missing rebuild has the same effect.

Connection refused on port 9000

The port is not reachable from where you test. In Docker, test from inside the container network. In Kubernetes, check that the container exposes the port and a NetworkPolicy allows your monitoring.

Readiness fails while liveness passes

The process runs but cannot serve, most often because the database is unreachable. Read the pod logs and check the database settings.

Probes fail after turning on HTTPS

When Keycloak serves HTTPS, the management interface does too. Set the probe scheme to HTTPS.

Security notes

  • Never publish port 9000 to the internet. Metrics can reveal realm names, traffic patterns and internals.
  • Do not route /health or /metrics through your public reverse proxy.
  • Limit who can reach the management port with firewall rules or a NetworkPolicy.

Best practices

  • Alert on readiness across all nodes, not only on pods running.
  • Chart request latency and error rates next to the database’s own metrics.
  • Keep liveness lenient and readiness strict.
  • Test probes after every upgrade.

Managed hosting takes this off your plate: we run upstream Keycloak on a dedicated cluster per customer. See pricing.

Questions

Frequently asked questions

What port does Keycloak use for health checks?

The management port, 9000 by default. You can change it with `http-management-port`. The sign-in pages stay on 8080 or 8443.

Why does Keycloak /health return 404?

Health checks are off until you set `health-enabled=true`, and they are served on the management port, not on 8080. If you start with `--optimized`, run `kc.sh build` after turning them on.

How do I enable metrics in Keycloak?

Set `metrics-enabled=true` and scrape `/metrics` on port 9000. Add `http-metrics-histograms-enabled=true` for request latency histograms.

What is the difference between /health/ready and /health/live?

Ready means the server can take traffic, including a working database connection. Live means the process is running. Use ready to route traffic and live to decide on restarts.

Which Kubernetes probes should I use for Keycloak?

A startup probe on `/health/started`, a readiness probe on `/health/ready` and a liveness probe on `/health/live`, all on port 9000. The Keycloak Operator sets them up for you.

How do I add a Docker health check without curl?

The Keycloak image has no curl. Use bash’s `/dev/tcp` to send an HTTP request to `/health/ready` on port 9000 and check for a 200 response, as the generated health check does.

Can I get login counts per realm from Keycloak metrics?

Yes, with the `user-event-metrics` feature and `event-metrics-user-enabled=true`. Keycloak then counts user events, such as logins and login errors, per realm.

Do health checks work in start-dev mode?

Yes. With `health-enabled=true`, development mode serves the same endpoints on port 9000. It is a handy way to test probes on your own machine before you deploy.

Should the metrics endpoint be public?

No. Keep port 9000 inside your network and let Prometheus scrape it there. Metrics reveal details an attacker can use.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.