# Health checks

Source: https://tiltas.openpanel.sh/docs/services/health

> How the Device that hosts a Service checks that the program behind it answers, and what the console shows.

The Device that hosts a Service checks now and then that the Service's target answers, and reports the result. Nothing
to set up: every Service is checked.

## What is checked

| Kind | Check | Answering when |
|---|---|---|
| Web | `GET /` to the target, with the Service name as `Host` | a response comes within 2 seconds, with any status below 500. A redirect or a "not found" still counts. |
| TCP | a TCP connection to the target (on the first listed port, if the target has none) | the connection opens within 2 seconds |

A TCP Service whose target has no port and lists no ports can only be checked for its address: the check passes when the
target's name resolves to an address the hosting Device may reach.

The check follows the same [target rules](/docs/services/targets) as visitors, so a target the Device may not reach
always shows as not answering.

## How often

With every report the hosting Device sends: every 60 seconds, and soon after any change to its Services. An offline
Device sends no reports, so its Services keep their last result.

## In the console

**Services** shows one of three states, with the time of the last check under it:

| State | Means |
|---|---|
| **Answering** | The last check passed. |
| **Not answering** | The last check failed: the program is stopped, listens on another port, or answers with a server error. |
| **Not checked yet** | The hosting Device has not reported since the Service was created, for example because it is offline. |

The API returns the same as `health.ok` (`true`, `false` or `null`) and `health.checked_at`.

A failed check does not close the Service: visitors still reach the target, and get **Service unreachable** while it is
down.

## When it says Not answering

1. On the hosting Device, check that the program runs and listens where the target says, for example
   `curl -I http://localhost:3000/` for a Web Service.
2. A web program that answers `/` with an error (status 500 or higher) shows as not answering even when other pages
   work.
3. A target on the LAN must be reachable from the hosting Device itself.

More in [Troubleshooting](/docs/troubleshooting/cant-reach).
