# Health checks and rollbacks

> Configure health checks and rollbacks on OnePloy: HTTP or command checks before traffic switches, and instant rollback to an earlier image.

Source: https://oneploy.dev/docs/applications/health-checks-and-rollbacks/  
Updated: 2026-11-02

A health check tells OnePloy when a new container is ready for traffic, and a rollback switches an application back to an image that was built earlier. Configure health checks on the application’s **Healthcheck** page and roll back from the **Rollback** page.

## How do I configure a health check?

1. Open the application and go to **Healthcheck**.
2. Enable the health check and choose a **Check type**.
3. Fill in the fields for that type and save.
4. Redeploy so the new container uses the check.

### HTTP request checks

OnePloy sends the request from inside the container and evaluates the response.

| Field | Meaning |
| --- | --- |
| Method | HTTP method, usually `GET`. |
| Scheme | `http` or `https`. |
| Host | Host to call, normally `localhost`. |
| Port | Port to call. Uses the first exposed port when empty. |
| Path | Path to request, for example `/health`. |
| Expected code | Status code that counts as healthy, for example `200`. |
| Expected response text | Optional text the response body must contain. |

### Container command checks

Run a single command inside the container. The container is healthy when the command exits with code 0. Shell expansion is not applied, so use a plain executable and arguments.

### Timing

| Field | Meaning |
| --- | --- |
| Interval (seconds) | Time between checks. |
| Timeout (seconds) | How long one check may take. |
| Retries | Failed checks in a row before the container is marked unhealthy. |
| Start period (seconds) | Grace period after start before failures count. |

> **Tip:** Your image must include the tool the check uses. An HTTP check needs `curl` or `wget` available in the container.

## How do I roll back a deployment?

1. Open the application and go to **Rollback**.
2. Choose **Reload images** to list the images still stored on the server, with the time each was built.
3. Choose **Rollback** next to the image you want.

Rollback starts the stored image directly, without rebuilding. Only images tagged with a commit SHA or a pull request tag can be rolled back to.

## How many images are kept?

Set **Images to keep** on the Rollback page. Set it to `0` to keep only the running image. Pull request images are always removed during cleanup. If image retention is turned off in the server’s settings, turn it on there first, otherwise this setting has no effect.

## Can I roll back through the API?

Yes. List available images, then roll back to one:

```bash
curl -H "Authorization: Bearer $API_TOKEN" \
  https://app.oneploy.dev/api/v1/applications/APP_UUID/rollback-images

curl -X POST -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"commit":"3f9c2a1"}' \
  https://app.oneploy.dev/api/v1/applications/APP_UUID/rollback
```

The `commit` field is the image tag to return to. The rollback endpoint needs a token with the `deploy` permission.
