Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

A GitHub Actions run is stuck and the Cancel button does nothing

ErrorWorkflow stuck and not cancellable

Short answer

Cancel does not kill a run at once. The server re-checks each job's if condition, so a job or step with if: always() keeps running, and the server force-terminates after a 5 minute timeout. When a run still does not respond, send POST /repos/OWNER/REPO/actions/runs/RUN_ID/force-cancel.

  • Applies to GitHub Actions, GitHub CLI 2.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the run id and its status, then try the normal cancel once.

    gh run list --limit 5
    gh run cancel RUN_ID
  2. 2Match what you see, then jump to its fix

    1. 1The run shows cancelling, but a cleanup or report job keeps goingA job or step has if: always()Fix
    2. 2The run takes minutes to end after cancel, then endsThe process ignores the stop signalsFix
    3. 3The run has been in progress for hours on the same stepThe run has no timeout and a step waits foreverFix

What does the error look like?

  • Workflow stuck and not cancellable
  • Cancel workflow does nothing and the run stays in progress

Cause 1 of 3

A job or step has if: always()

1Check

On cancel, the server evaluates the if condition again for running jobs and steps. A condition that is true, such as always(), lets them continue. With no condition the default is success(), which stops.

grep -n -E 'if: .*(always|cancelled)\(' .github/workflows/*.yml

2Fix

Use if: ${{ !cancelled() }} for steps that should run after a failure but not after a cancel, and keep always() only for cleanup that is short and cannot hang.

- name: Upload report
  if: ${{ !cancelled() }}
  uses: actions/upload-artifact@v4
  with:
    name: report
    path: report/

3Verify

Cancel a test run and check that it stops within a minute.

gh run cancel RUN_ID && gh run view RUN_ID

Confirmed by docs.github.com

Did this fix it?

Cause 2 of 3

The process ignores the stop signals

1Check

The runner sends SIGINT, then SIGTERM after 7500 ms, then kills the process tree 2500 ms later. A process that traps signals, or a job waiting on a hung child, can delay this. After the 5 minute cancellation timeout the server forcibly terminates all jobs.

gh run view RUN_ID --json status,conclusion,jobs

2Fix

Wait the full 5 minutes. If the run is still in progress after that, use the force-cancel endpoint below. For the future, avoid scripts that trap SIGINT without exiting.

gh api -X POST repos/OWNER/REPO/actions/runs/RUN_ID/force-cancel

3Verify

The run status turns to cancelled.

gh run view RUN_ID --json status,conclusion

Confirmed by docs.github.com

Did this fix it?

Cause 3 of 3

The run has no timeout and a step waits forever

1Check

A command waiting for input, a lock or a network response never ends by itself.

gh run view RUN_ID --log | tail -n 20

2Fix

Cancel or force-cancel the run, then add timeout-minutes to the job. The default is 360 minutes, so a hung run can sit for hours.

jobs:
  build:
    runs-on: ubuntu-24.04
    timeout-minutes: 30

3Verify

A hung run is now stopped by GitHub after the limit.

gh run list --limit 5

Confirmed by docs.github.com

Did this fix it?

How do I stop it coming back?

  • Set timeout-minutes on every job.
  • Use !cancelled() instead of always() for post-failure steps.
  • Keep cleanup steps short and free of waits.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

docker pull or push to ghcr.io fails with 'denied'

Error response from daemon: denied

ghcr.io refuses a pull or push when Docker is not logged in, when the token lacks the package scope, or when the workflow's GITHUB_TOKEN has no packages permission or no access to that package.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.