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.
ERROR: failed to solve: error writing layer blob: failed to export cache:
unexpected status code from cache service: 503Common 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
- Set cache-from and cache-to with type=gha and mode=max for full layer caching.
- Ensure the buildx builder uses the docker-container driver.
- Re-run on a transient cache-service error.
- uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=maxHow 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.