A GitHub Actions job hangs for hours: set a timeout
A run stays In progress for hours with no new log outputShort answer
Without a setting, a job runs until it finishes or reaches 360 minutes, and a hung step uses all of that time. Set timeout-minutes on the job, and on any step that tends to hang. There is no single workflow-level key; the value goes on each job.
Fix it fast
1Find out which cause you have
Check which jobs and steps already carry a timeout. Anything without one can run for the default six hours.
grep -n "timeout-minutes" .github/workflows/*.yml2Match what you see, then jump to its fix
- 1
A hung run is only cancelled after 360 minutes.The job has no timeout-minutes, so the default of 360 appliesFix - 2
The log stops inside one step, such as a network call or an interactive prompt.One step hangs, while the rest of the job is fineFix - 3
The job is cancelled earlier than the timeout-minutes you set.A limit longer than the runner allowsFix
- 1
What does the error look like?
A run stays In progress for hours with no new log outputThe run is cancelled after 360 minutes
Cause 1 of 3
The job has no timeout-minutes, so the default of 360 applies
1Check
timeout-minutes is the maximum number of minutes GitHub lets a job run before cancelling it. The default is 360.
grep -n -B3 "runs-on" .github/workflows/*.yml2Fix
Set a limit a little above the longest healthy run of that job.
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 203Verify
Break the job on purpose with a sleep longer than the limit: it is cancelled at 20 minutes.
gh run list --limit 3Confirmed by docs.github.com
Cause 2 of 3
One step hangs, while the rest of the job is fine
1Check
A step has its own timeout-minutes: a positive integer, with fractions not supported. When it is reached, the runner kills the step's process.
grep -n -B2 -A4 "run:" .github/workflows/*.yml2Fix
Put a short limit on that step, so the failure is clear and fast.
steps:
- name: Wait for service
run: ./wait-for-service.sh
timeout-minutes: 53Verify
A hung step now fails after five minutes with the job marked failed.
gh run watch --exit-statusConfirmed by docs.github.com
Cause 3 of 3
A limit longer than the runner allows
1Check
If timeout-minutes is longer than the runner's execution time limit, the job is cancelled when that limit is reached. The GITHUB_TOKEN also expires when the job finishes or after 24 hours at most.
grep -n "timeout-minutes" .github/workflows/*.yml2Fix
Set a value inside the runner's limit, or split the work into several jobs.
jobs:
part-one:
timeout-minutes: 1203Verify
The job completes or is cancelled at the value you set.
gh run list --limit 3Confirmed by docs.github.com
How do I stop it coming back?
- Set timeout-minutes on every job as part of the workflow template you copy.
- Choose the value from your longest healthy run, not from the 360 default.
- Put a step-level timeout on network waits and anything that can prompt for input.
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 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 fixServers
A local composite action in GitHub Actions cannot be found
The action folder is in the repository but the runner reports that its action.yml cannot be found
A local action is read from the checked-out repository.
3 causes, each with a fix