0
0
AirflowHow-ToBeginner ยท 3 min read

How to Pause and Unpause DAG in Airflow Quickly

To pause or unpause a DAG in Airflow, use the CLI commands airflow dags pause and airflow dags unpause . Alternatively, you can toggle the pause state in the Airflow web UI by clicking the pause button next to the DAG name.
๐Ÿ“

Syntax

The commands to pause and unpause a DAG in Airflow are simple and use the airflow dags CLI group.

  • airflow dags pause <dag_id>: Pauses the specified DAG, stopping it from scheduling new runs.
  • airflow dags unpause <dag_id>: Unpauses the DAG, allowing it to schedule new runs again.

Replace <dag_id> with the actual ID of your DAG.

bash
airflow dags pause <dag_id>
airflow dags unpause <dag_id>
๐Ÿ’ป

Example

This example shows how to pause and then unpause a DAG named example_dag using the CLI.

bash
airflow dags pause example_dag
# Output: DAG example_dag is paused

airflow dags unpause example_dag
# Output: DAG example_dag is unpaused
Output
DAG example_dag is paused DAG example_dag is unpaused
โš ๏ธ

Common Pitfalls

Common mistakes when pausing or unpausing DAGs include:

  • Using the wrong dag_id which causes the command to fail silently or show an error.
  • Expecting the pause to stop currently running tasks; pausing only prevents new runs from starting.
  • Not refreshing the Airflow UI after changing pause state, so the UI may show outdated status.

Always verify the DAG ID and check the status after running the commands.

bash
## Wrong DAG ID example (wrong_dag does not exist)
airflow dags pause wrong_dag
# Output: DAG with id wrong_dag not found

## Correct usage
airflow dags pause example_dag
# Output: DAG example_dag is paused
Output
DAG with id wrong_dag not found DAG example_dag is paused
๐Ÿ“Š

Quick Reference

ActionCommandEffect
Pause DAGairflow dags pause Stops scheduling new DAG runs
Unpause DAGairflow dags unpause Allows scheduling new DAG runs
Toggle in UIClick pause button next to DAG nameSwitches pause state visually
โœ…

Key Takeaways

Use airflow dags pause <dag_id> to stop new DAG runs from scheduling.
Use airflow dags unpause <dag_id> to resume scheduling DAG runs.
Pausing does not stop currently running tasks; it only prevents new runs.
You can also pause/unpause DAGs via the Airflow web UI by toggling the pause button.
Always verify the DAG ID and refresh the UI to see the current pause state.