How can I stop/kill a running task on Airflow UI? I am using LocalExecutor
.
Even if I use CeleryExecutor
, how do can I kill/stop the running task?
6 Answers
In the DAGs screen you can see the running tasks:
On 'Recent Tasks' press the running icon and Airflow will automatically run the search query with the filters for the Dag Id and State equal to 'running' and show the results on the Task Instances screen (you can find it manually on the tab Browse > Task Instances).
There you can select the presented tasks and set them to another state or delete them.
Please notice that if the DAG is currently running, the Airflow scheduler will start again the tasks you delete. So either you stop the DAG first by changing its state or stop the scheduler (if you are running on a test environment).

- 15,563
- 19
- 81
- 112

- 387
- 2
- 4
-
2Will it not restart the task even if i stop the scheduler and delete the task? – Chetan J Apr 27 '17 at 05:08
-
1If you stop the scheduler and you do not want that task to run again, just set the task manually to the state "success" instead of deleting it. If you just delete it, the scheduler will run that task again. – Jorge Almeida Apr 28 '17 at 14:09
-
32I paused the DAG and deleted the records but the processes are still running. Is there a way to not only change the state according to the executor but also kill the underlying process? – stefanobaghino Jul 28 '17 at 12:44
Simply set the task to failed state will stop the running task.
[2019-09-17 23:53:28,040] {logging_mixin.py:82} INFO - [2019-09-17 23:53:28,039] {jobs.py:2695} WARNING - State of this instance has been externally set to failed. Taking the poison pill.
[2019-09-17 23:53:28,041] {helpers.py:240} INFO - Sending Signals.SIGTERM to GPID 20977

- 601
- 6
- 14
-
2This is the solution that worked for me. For others finding this post, more info can be found here: https://issues.apache.org/jira/browse/AIRFLOW-2285 – lampShadesDrifter Oct 09 '19 at 23:39
-
Works for me also. Other answers imply non-deterministic, but you can check in the logs after changing the state. – jabberwocky Jul 18 '20 at 13:21
-
This isn't the best plan, if the task has any retries left, it will keep retrying. – szeitlin Sep 02 '20 at 15:48
from airflow gitter (@villasv)
" Not gracefully, no. You can stop a dag (unmark as running) and clear the tasks states or even delete them in the UI. The actual running tasks in the executor won't stop, but might be killed if the executor realizes that it's not in the database anymore. "

- 3,135
- 4
- 27
- 43
As menioned by Pablo and Jorge pausing the Dag will not stop the task from being executed if the execution already started. However there is a way to stop a running task from the UI but it's a bit hacky.
When the task is on running
state you can click on CLEAR
this will call job.kill()
the task will be set to shut_down
and moved to up_for_retry
immediately hence it is stopped.
Clearly Airflow did not meant for you to clear tasks in Running
state however since Airflow did not disable it either you can use it as I suggested. Airflow meant CLEAR
to be used with failed
, up_for_retry
etc... Maybe in the future the community will use this bug(?) and implement this as a functionality with "shut down task" button.

- 1,305
- 5
- 19
- 46
AirFlow Version: v2.2.2 and above
- Go to AirFlow home page and search you Dag.
- Under the "Runs" status column press on the running status(green circle).
- You can choose a specific DAG run or, in the check box above choose all.
Then on the "Action" button, choose your relevant action

- 398
- 6
- 14