Skip to content
Latchkey

GitHub Actions buildx "failed to export gha cache"

Buildx can export layer caches to the GitHub Actions cache via cache-to type=gha. Missing scope inputs or a transient cache-service hiccup can fail the export. Config issues are deterministic; a one-off cache-service 5xx is transient.

What this error means

The build succeeds building layers but fails exporting them to the gha cache backend at the end of the step.

github-actions
ERROR: failed to solve: error writing layer blob: failed to export cache:
unexpected status code from cache service: 503

Common causes

Missing or wrong cache-to configuration

cache-to type=gha is malformed or the build lacks the inputs buildx needs to address the cache.

Transient cache-service error

An intermittent 5xx from the Actions cache service interrupts the export.

How to fix it

Configure gha cache export correctly

  1. Set cache-from and cache-to with type=gha and mode=max for full layer caching.
  2. Ensure the buildx builder uses the docker-container driver.
  3. Re-run on a transient cache-service error.
.github/workflows/build.yml
- uses: docker/build-push-action@v6
  with:
    context: .
    cache-from: type=gha
    cache-to: type=gha,mode=max

How to prevent it

  • Use the docker-container driver and a well-formed type=gha cache config.
  • On Latchkey managed runners, transient cache-service errors during layer export are retried automatically so a one-off export blip does not fail the build.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →