Timeout allows you to set a maximum duration for a task run.

What is timeout

If the task run exceeds the specified duration, Kestra will automatically stop the task run and mark it as failed. This is useful for tasks that may hang and run indefinitely.

Timeout is often used as a cost control mechanism for cloud-based workflows. Imagine a Snowflake query or an AWS Batch job that runs for hours leading to unexpected costs. By setting a timeout, you can ensure that the task run will not exceed a certain duration.


In this example, the costly_query task will sleep for 10 seconds, but the timeout is set to 5 seconds, leading to a failed task run.

id: timeout
namespace: dev
description: This flow will always fail because of a timeout.

  - id: costly_query
    type: io.kestra.plugin.scripts.shell.Commands
    runner: PROCESS
      - sleep 10
    timeout: PT5S