Troubleshoot Bazel remote-cache misses.

A hit-rate percentage is the beginning of an investigation, not the answer. Diagnose misses at the action level and compare the exact inputs that determine each action key.

A remote cache stores completed action results so another build can reuse them. An action is one build step, such as a compile. Reuse depends on the action’s declared inputs, command, environment and execution platform, plus a reachable cache with the result available.

Start with the symptom

A cache service error, a changed action key and a slow build with many hits need different investigations. Use the matching path below.

What you observeWhat to check firstDetailed guide
The cache returns UNAVAILABLE or a permission errorCheck the endpoint, credentials and service health before comparing action keys.Troubleshoot cache connectivity
The same target misses on two machinesCompare the action command, inputs, environment and execution platform. The same source revision alone is not enough.Compare machines and CI
An unchanged target starts missingFind the first changed action, then trace its changed inputs or configuration.Investigate action-key changes
Comparable actions still execute with remote caching enabledCheck cache-read policy, action cacheability, instance name, uploads and retention.Review common miss causes
The hit rate is high but the build stays slowInspect analysis, critical path, cache requests, transfers and execution queues.Interpret cache-hit metrics

Capture two comparable builds

Choose one target that rebuilds unexpectedly. Record the Bazel version, source revision, configuration, cache endpoint, instance name and platform on both machines. Keep credentials out of any files you share. Start with a build that already reaches your team’s cache successfully.

Replace //your/package:target with your target. Keep your existing cache configuration. These commands capture a JSON execution log, Build Event Protocol (BEP) events and a timing profile; check flag availability with your installed Bazel version.

bazel version
bazel build //your/package:target \
  --execution_log_json_file=/tmp/cache-build-a.exec.json \
  --build_event_json_file=/tmp/cache-build-a.bep.json \
  --profile=/tmp/cache-build-a.profile.gz

Repeat for the comparison build with cache-build-b filenames, using another machine or the configuration under investigation. Select only one execution-log format per invocation. Bazel also supports compact logs; the field guide covers that format and its parser.

A warm local action cache can avoid execution and remote lookups, so a second unchanged build may not exercise the remote cache. For an isolated diagnosis, use a fresh disposable workspace or output base with the same build configuration. Avoid adding cleanup steps to the normal CI pipeline.

The execution log describes actions. BEP records build and test events. The profile explains where elapsed time went. BEP alone does not contain all the inputs needed to explain an action-key change.

Compare one action before changing the cache

Match the same target and action type in both execution logs. A raw file diff can include ordering noise; compare the corresponding action records. The Bazel action-diff tool compares JSON records locally in your browser. It highlights changed fields; it does not calculate Bazel’s action digest or establish the cause by itself.

Inputs and tools
Check file digests, generated files, compiler versions and declared tools. Trace the earliest changed input rather than treating every downstream miss as a separate fault.
Command and environment
Look for absolute paths, inherited --action_env values, compilation modes and stamping differences between CI and developer builds.
Execution platform
Compare the selected toolchain and platform properties. Actions intended for different operating systems or architectures may correctly have different keys.
Cache policy and namespace
Check --remote_accept_cached, --remote_upload_local_results, --remote_instance_name and rule tags such as no-remote-cache. Verify the effective configuration after --config expansion.

If the key-forming fields match but reuse still fails, check whether the result was uploaded, whether the reader uses the same cache namespace, and whether the action result and referenced output blobs remain available. A miss alone does not prove eviction. Use the execution-log debugging walkthrough for the detailed investigation.

Verify both reuse and elapsed time

Change one identified cause and rerun the same target under comparable conditions. Confirm the relevant action result is reused and the build remains correct. Preserve the before and after logs so you can distinguish an intended input change from accidental configuration drift.

Then compare total elapsed time and the profile. A higher hit percentage can coexist with slow analysis, cache requests, downloads or remote queues. The cache-metrics explanation covers that distinction; the Bazel performance guide helps identify the next bottleneck.

For ongoing investigation, Hermetiq cache analytics connects recorded cache behavior to builds and actions. Available diagnoses depend on the data sources connected to your project.

Choose the next cache article

Reference: Bazel remote caching, remote-cache debugging, and the Bazel command-line reference. Check behavior against the version you run.

Lab

A changed environment value: miss, diagnosis, verification

Recorded November 19, 2026 · Bazel 9.2.0 · macOS arm64 client · Hermetiq Cloud shared Buildbarn workers

The same manifest target hit the remote cache, missed after one declared environment value changed, then hit again when we restored that value. Each command used a fresh output base. The source input and shell arguments stayed the same.

StepRecorded outcomeEvidence
Repeat unchanged1 remote cache hit; 0 remote executions
Bazel exit code 0
Action records
Bazel event excerpt
Set PILOT_MODE=debug1 remote execution; 0 remote cache hits
Bazel exit code 0
Action records
Bazel event excerpt
Restore PILOT_MODE=release1 remote cache hit; 0 remote executions
Bazel exit code 0
Action records
Bazel event excerpt

How Hermetiq explained the miss

Hermetiq’s find_cache_events returned ENV_CHANGED for //:manifest. Its configuration comparison found the added --define=PILOT_MODE=debug. In this rule, that definition sets the action’s PILOT_MODE environment variable.

The execution records independently show release changing to debug. The action key changed from 156cd87b161e… to 88fb82d85bcd…; the input root, output paths and platform hashes stayed the same in the cache-event comparison. Restoring release restored the original key and cache hit.

Barn Owl identified the change as expected invalidation. We checked that explanation against the records. The response also reported a changed command digest: the Remote Execution API’s Command includes environment variables, so that digest change alone does not establish that shell arguments changed.

Inspect the cache-miss evidence · Inspect the configuration comparison · Check the Command definition

This small fixture verifies a setup and investigation workflow. It does not measure production performance, migration effort, flake-detection accuracy, or every toolchain’s compatibility. The downloadable JSON includes selected evidence fields, with local paths and project identifiers removed where noted.

Download source and recorded evidence · Reproduction steps and scope · Offline verifier

Try the shared-worker setup in your own project

Investigate your own build data.

Hermetiq connects Bazel and Buildbarn telemetry to the answers your engineers and AI agents need. See which data sources power the analysis.

Explore Hermetiq for Bazel →

Technical review: November 19, 2026 · Verify flags, metric availability, and behavior against the versions deployed in your environment.