How to re-run a failed GitHub Actions job with debug logging (web and gh CLI)
Your job failed, and the log stops at one error line that says nothing about what led up to it. You can get more detail by re-running the failed jobs with debug logging on. On the run's summary page, open the Re-run jobs dropdown, click Re-run failed jobs, tick Enable debug logging, then click Re-run jobs. In a terminal, gh run rerun RUN_ID --failed --debug does the same thing.
That checkbox turns on two kinds of extra logging for the re-run: step debug logging and runner diagnostic logging. Here's how to use each path, what you get back, and the limits worth checking before you click.
Re-run failed jobs with debug logging on the web
Pick the workflow in the left sidebar, then click the run's name in the list to open the run summary. From there:
- In the upper-right corner, open the Re-run jobs dropdown and click Re-run failed jobs.
- Tick Enable debug logging.
- Click Re-run jobs.
Only want one job, not every failed one? Under Jobs in the left sidebar, click the re-run icon next to that job.
GitHub's docs say anyone who has access to run a workflow can turn on runner diagnostic logging and step debug logging for a workflow re-run.
Re-run with debug logging from the gh CLI
gh run rerun has a --debug flag that reruns with debug logging. Add --failed to rerun only the failed jobs, or --job with a job ID to rerun one job. These are GitHub's own examples:
gh run rerun RUN_ID --debug
gh run rerun RUN_ID --failed --debug
gh run rerun --job JOB_ID --debugLook at the words "including dependencies" in the gh help for --failed and --job. When you re-run failed jobs or one job, GitHub also re-runs the jobs that depend on them. Jobs that aren't included keep their outputs from the previous attempt.
What the debug re-run adds to your logs
Start with step debug logging. It makes a job's logs more verbose during and after the job runs. The extra events come from the action's author and the runner process. The Actions toolkit docs call this the primary way to debug job failures caused by failed steps.
Runner diagnostic logging is a different thing. It adds two log files to the log archive: the runner process log, about coordinating and setting up runners, and the worker process log, which logs the execution of the job. To read them, download the run's log archive and open the runner-diagnostic-logs folder.
The catch: the toolkit docs say you only need runner diagnostic logs if you think there's an infrastructure problem with GitHub Actions and you want the product team to check the logs. For a failing test or build step, start with the step logs.
| Kind | Turned on by | Where you read it |
|---|---|---|
| Step debug logging | ACTIONS_STEP_DEBUG set to true, or the Enable debug logging box on a re-run | More debug events in the step logs |
| Runner diagnostic logging | ACTIONS_RUNNER_DEBUG set to true, or the Enable debug logging box on a re-run | The runner-diagnostic-logs folder in the downloaded log archive |
Turn on debug logging for every run
If the failure is rare and you can't tell which run will hit it, a one-off debug re-run may come back green and teach you nothing. The other route is a secret or variable named ACTIONS_STEP_DEBUG, set to true in the repository that holds the workflow. ACTIONS_RUNNER_DEBUG works the same way for runner diagnostic logs. If both a secret and a variable are set, the secret's value wins.
Check your access first. To create secrets or variables in an organization repository, you need write access. In a personal account repository, you need to be a collaborator.
The toolkit docs say every action that runs while the secret is enabled shows debug events, in both the downloaded logs and the web logs. So remove the secret, or set it back, once you've caught the failure.
Add your own debug-only steps
Want extra output of your own on a debug run, like a test runner's full report? The runner.debug context is set only when debug logging is on, and its value is always 1. GitHub's contexts reference suggests using it to switch on extra debugging or verbose logging in your own job steps.
You can use the runner context to run a step only when debug logging is enabled.
Compare the debug attempt with the one that failed
A re-run uses the same GITHUB_SHA and GITHUB_REF as the original event, so both attempts run against the same commit. On the run page, open the Latest dropdown to the right of the run name and click a previous run attempt to see the one that failed.
In the terminal, gh run view has the flags you want. --log-failed shows the log for any failed steps, --log shows the full log, and --attempt picks the attempt number.
gh run view 12345 --attempt 3
gh run view --log --job 456789If the debug attempt passes, don't call it fixed. Same commit, one red attempt and one green one: treat that as a possible flake and read both logs side by side.
Limits to check before you re-run
- You can re-run a workflow run, its failed jobs or specific jobs up to 30 days after its initial run.
- A workflow run can be re-run a maximum of 50 times, and that count includes both full re-runs and re-runs of some of its jobs.
- Re-runs use the privileges of the actor who first triggered the workflow.
Before you spend a debug re-run: is it a known flake?
A debug re-run means waiting for the job again. If the job fails on and off, that wait can end in a green run and no new clue.
We make FlakeRadar at Bright Labs for this exact decision. It's a free Chrome extension for GitHub pull requests. It reads the repository's own GitHub Actions history and labels each failing job: Known flake, New failure, Also failing on the default branch, or Not enough history. A job counts as flaky when it failed and then passed on the same commit. Each label shows its counts, time window and date. The free plan covers public repositories, and FlakeRadar is not affiliated with or endorsed by GitHub.
A Known flake label is evidence, not a promise. If the failure matters, the debug re-run above is still how you find out what actually happened.
Sources
- GitHub Docs on enabling debug logging in Actions
- GitHub Docs on re-running workflows and jobs
- GitHub Actions contexts reference (runner context)
- Actions toolkit guide to action debugging
- GitHub CLI manual for gh run rerun
- GitHub CLI manual for gh run view
Questions
Does ticking Enable debug logging change my repository settings?
It turns on runner diagnostic logging and step debug logging for that re-run. Debug logging through the repository is a separate route: the ACTIONS_STEP_DEBUG and ACTIONS_RUNNER_DEBUG secrets or variables in the repository that holds the workflow.
Can I re-run an old failed job with debug logging?
Only within 30 days. You can re-run a workflow run, its failed jobs or specific jobs up to 30 days after its initial run.
Where are the runner diagnostic logs?
They're extra files in the run's log archive. Download the log archive of the workflow run and open the runner-diagnostic-logs folder.
Does the re-run use my permissions?
Not necessarily. Re-runs use the privileges of the actor who first triggered the workflow.
Related
- Is the failing check on your PR also broken on main? How to check the default branch first
- How to see the failed attempt after you re-run a GitHub Actions job
- Load jQuery from Google's CDN with a local fallback: the snippet, SRI and how to test it
- Does re-running a GitHub Actions job pick up the latest main? Why your PR is still red