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.
WARNING: Writing to Remote Cache:
io.grpc.StatusRuntimeException: INTERNAL: Failed to upload output
'bazel-out/k8-fastbuild/bin/foo/lib.a': UNAVAILABLE: Connection closedCommon 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
- Use a credential with write scope if CI should populate the cache.
- Or set the cache to upload-optional so a failed write does not fail the build.
- Re-run to confirm uploads now succeed or are skipped cleanly.
build --remote_upload_local_results=true
build --incompatible_remote_build_event_upload_respect_no_cacheMake cache writes non-fatal
Treat the remote as best-effort so an upload failure logs a warning instead of failing the job.
build --remote_local_fallback
build --remote_upload_local_results=falseHow 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.