A GitHub Actions run is stuck and the Cancel button does nothing
Workflow stuck and not cancellableShort 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.
Fix it fast
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_ID2Match what you see, then jump to its fix
What does the error look like?
Workflow stuck and not cancellableCancel 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/*.yml2Fix
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_IDConfirmed by docs.github.com
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,jobs2Fix
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-cancel3Verify
The run status turns to cancelled.
gh run view RUN_ID --json status,conclusionConfirmed by docs.github.com
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 202Fix
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: 303Verify
A hung run is now stopped by GitHub after the limit.
gh run list --limit 5Confirmed by docs.github.com
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
A GitHub Actions job hangs for hours: set a timeout
The run is cancelled after 360 minutes
Without a setting, a job runs until it finishes or reaches 360 minutes, and a hung step uses all of that time.
3 causes, each with a fixServers
Docker push to Artifact Registry fails from GitHub Actions with a permission error
Permission 'artifactregistry.repositories.uploadArtifacts' denied on resource
The identity your workflow authenticates as lacks the permission artifactregistry.repositories.uploadArtifacts on the target repository.
4 causes, each with a fixServers
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 fixServers
git says it could not read Username for https://github.com in a build or CI job
fatal: could not read Username for 'https://github.com': No such device or address
Git asked for HTTPS credentials and there was no terminal to ask on, so it gave up.
3 causes, each with a fixServers
upload-artifact fails because the artifact storage quota is full
Create Artifact Container failed: Artifact storage quota has been hit. Unable to upload any new artifacts
Uploads fail when your account's shared artifact storage is used up.
3 causes, each with a fixServers
configure-aws-credentials says no OpenID Connect provider exists for GitHub
No OpenIDConnect provider found in your account for https://token.actions.githubusercontent.com
AWS has no IAM identity provider for GitHub's token issuer in the account that holds the role.
3 causes, each with a fix