> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/3.0/harness-platform-resources/overview/strategy/timeout.md).

# Timeout

Set a maximum run time for a stage or step. Harness terminates it if it exceeds the timeout duration.

**Timeout duration** sets the maximum time a stage or step is allowed to run. If it is still running when the timeout expires, Harness terminates it and marks it as Expired. The default for stages is `24h`.

## What you will learn

* How to set a maximum run time for a stage or step using the `timeout` key
* What duration formats are accepted
* How a timed-out stage is marked and how to handle timeouts using on-failure rules

***

## YAML

Use the `timeout` key on the stage:

```yaml
stages:
  - name: build
    id: build
    timeout: 30m
    steps:
      - name: compile
        id: compile
        run:
          script: make build
```

***

## Duration format

| Format   | Example  | Equivalent          |
| -------- | -------- | ------------------- |
| Seconds  | `90s`    | 1 minute 30 seconds |
| Minutes  | `30m`    | 30 minutes          |
| Hours    | `2h`     | 2 hours             |
| Days     | `1d`     | 24 hours            |
| Combined | `1h 30m` | 1 hour 30 minutes   |

***

## Behavior

* When a stage times out, it is marked as **Expired** and the pipeline is stopped.
* You can configure [On failure](/harness-platform/3.0/harness-platform-resources/overview/strategy/on-failure.md) with `errors: [timeout]` to handle timeouts specifically, for example to retry the stage.
* Individual steps can also have their own timeouts. If a step times out before the stage timeout is reached, the step expires first.

{% hint style="info" %}
Set timeouts conservatively. A stage with no timeout (or `24h`) can hold up the pipeline for a full day if it hangs on a network call or a waiting step.
{% endhint %}

***

## Next steps

* Go to [On failure](/harness-platform/3.0/harness-platform-resources/overview/strategy/on-failure.md) to configure retry or abort behavior when a timeout occurs.
* Go to [Pipelines overview](/harness-platform/3.0/harness-platform-resources/overview.md) to review the pipeline model.
