Skip to content
Latchkey

Bazel "INTERNAL: Failed to upload" to remote cache in CI

Bazel finished an action and tried to store its outputs in the remote cache, but the upload failed. The status is often INTERNAL or PERMISSION_DENIED, pointing at a write-permission, size, or connectivity problem rather than a build error.

What this error means

A build logs "INTERNAL: Failed to upload ..." or "PERMISSION_DENIED" while writing to the remote cache; the action itself succeeded but caching it did not.

bazel
WARNING: Writing to Remote Cache:
io.grpc.StatusRuntimeException: INTERNAL: Failed to upload output
'bazel-out/k8-fastbuild/bin/foo/lib.a': UNAVAILABLE: Connection closed

Common causes

The credential lacks write access

A read-only token can fetch from the cache but cannot upload, so writes fail with PERMISSION_DENIED.

A dropped connection or size limit during upload

A network drop or a server-side blob size limit interrupts the upload and Bazel reports INTERNAL.

How to fix it

Grant write access or restrict to reads

  1. Use a credential with write scope if CI should populate the cache.
  2. Or set the cache to upload-optional so a failed write does not fail the build.
  3. Re-run to confirm uploads now succeed or are skipped cleanly.
.bazelrc
build --remote_upload_local_results=true
build --incompatible_remote_build_event_upload_respect_no_cache

Make cache writes non-fatal

Treat the remote as best-effort so an upload failure logs a warning instead of failing the job.

.bazelrc
build --remote_local_fallback
build --remote_upload_local_results=false

How to prevent it

  • Give CI a write-scoped credential only where it should populate the cache.
  • Keep cache uploads best-effort so a failed write does not fail the build.
  • Watch for server blob size limits on large outputs.

Frequently asked questions

What causes ""INTERNAL: Failed to upload""?
A read-only token can fetch from the cache but cannot upload, so writes fail with PERMISSION_DENIED.
How do I fix "INTERNAL: Failed to upload"?
Grant write access or restrict to reads

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card