Join us from October 8-10 in New York City to learn the latest tips, trends, and news about GraphQL federation and API platform engineering.Join us for GraphQL Summit 2024 in NYC
Start for Free

Health Checks in the Apollo Router

Determining the router's status

Health checks are often used by load balancers to determine whether a server is available and ready to start serving traffic.

The supports a basic HTTP-level health check. This is enabled by default and is served on port 8088 at the URL path /health. This returns a 200 status code if the HTTP server is successfully serving. You can change this by setting health_check:

enabled: true
path: /health # Optional, default: /health

Each option is configurable. For example, we can set our health check endpoint to

enabled: true
path: /healthz

We can also disable the health check endpoint:

enabled: false

Testing with curl

The following example demonstrates using the curl command to send a basic health check to an Apollo Router instance running at

$ curl -v ""
* Trying
* Connected to ( port 8088 (#0)
> GET /health HTTP/1.1
> Host:
> User-Agent: curl/7.79.1
> Accept: */*
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< vary: origin
< content-type: application/json
< content-length: 15
< date: Wed, 21 Sep 2022 17:10:45 GMT
* Connection #0 to host left intact


If you start the with trace logging enabled, you will see a log from the router for each health check:

--log apollo_router=trace
2023-01-23T17:42:04.640501Z apollo-router/src/axum_factory/ TRACE apollo_router::axum_factory::axum_http_server_factory: health check health=Health { status: Up } request=Request { method: GET, uri: /health, version: HTTP/1.1, headers: {"host": "", "user-agent": "curl/7.85.0", "accept": "*/*"}, body: Body(Empty) }

This may be helpful with confirming that health-checks are working correctly.

Using in a containers environment

The health check listens to by default, which won't allow connections issued from a network. While this is a safe default, other containers won't be able to perform health checks, which will prevent the router pod from switching to a healthy state.

You can change this by setting health_check:

enabled: true

Using with Kubernetes

In Kubernetes, you can configure health checks by setting readinessProbe and livenessProbe on the containers object of the resource definition:

# ... snipped for partial example ...
- name: router
# ... snipped for partial example ...
path: "/health"
port: 8088
path: "/health"
port: 8088
# ... snipped for partial example ...

See a more complete example in our Kubernetes documentation.

Using with Docker

Docker has a HEALTHCHECK instruction that tells Docker how to test whether a container is still working. These are defined in the Dockerfile when building your container:

HEALTHCHECK CMD curl --fail \
"" || exit 1

We don't define these in our example Dockerfiles, because they aren't commonly used. You can add them to your own images as needed.

Run with Docker
Rate articleRateEdit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy