3.1.6 BCR Infrastructure
recommendedBzlmod in 3.1.1 Bzlmod (MODULE.bazel) makes external dependencies feel simple, but production reliability depends on infrastructure below that friendly bazel_dep() surface. The Bazel Central Registry is only the metadata layer: Bazel asks a registry for module files and fetch instructions, then downloads source archives from whatever URLs those registry entries point at. If either layer fails, the build fails for a different reason, and the mitigation is different too.1,2
What the registry actually serves
An index registry is just a directory tree or static HTTP server. For each module version it serves the registry copy of MODULE.bazel, a source.json file describing how to fetch the source, and optional patches or overlay files.1 The source archive itself usually lives somewhere else.
That separation matters operationally. A healthy bcr.bazel.build endpoint does not guarantee that the archive URL in source.json is healthy, stable, or even still available.1,2 Conversely, mirroring source archives does not help if Bazel cannot fetch registry files in the first place. The full registry layout and custom hosting model are covered in 3.1.8 Registry Structure & Custom Registries.
Registry outages and archive outages are different failures
When the hosted BCR endpoint is unavailable, module resolution can fail before Bazel even starts downloading dependency sources. Hosted-registry incidents have a different recovery shape from archive outages: users can often get unstuck by pointing --registry at a mirrored or raw copy of bazelbuild/bazel-central-registry, because Bazel only needs static registry files at that stage.3,1
common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/
Archive failures are a separate problem. Many module entries still point at upstream release artifacts or GitHub archive endpoints. Archive checksum churn is the cautionary story here: GitHub-generated /archive/refs/... tarballs are not a stable byte-level API, so a server-side Git upgrade can change the SHA-256 of the downloaded archive even when the extracted source tree is effectively the same.2 That is why "it builds from BCR" is not the same thing as "it is insulated from upstream archive churn."
The safe default is to prefer static release artifacts that maintainers publish intentionally, then mirror those artifacts so Bazel has a second place to fetch from.2 mirror.bazel.build is the ecosystem's shared version of that pattern. Large organizations usually add their own mirror in front of the same artifacts.2
A fallback helps only if it fails independently of what it backs up, and the public endpoints do not. In the December 2025 *.bazel.build outage, releases.bazel.build (the Bazel binaries Bazelisk downloads), bcr.bazel.build, and mirror.bazel.build shared one managed TLS certificate. Its renewal failed without any alert, and all three went down together for about 13 hours. Most CI builds failed before module resolution started, because runners had no cached Bazel binary. Builds that worked around the binary and the registry could still fail on the archive mirror. Only builds with an up-to-date lockfile and a primed download cache could skip the registry.4 The mirror.bazel.build certificate had expired once before, in 2022.5 So the Bazel team's advice after the incident covers all three layers: host internal mirrors for Bazel release binaries, BCR metadata, and source archives.4 During an incident, Bazelisk's download location can be overridden with BAZELISK_BASE_URL, next to the --registry fallback above.3
The knobs maintainers actually use
There are several layers where you can add resilience:
- Registry authors can declare registry-wide source mirrors in
bazel_registry.json. Bazel prefixes the original source URL with each mirror base and tries those before the original URL.1 - Individual module versions can add
mirror_urlsinsource.jsonas explicit backups for a single archive.1 - Consumers can replace the default registry entirely with repeated
--registryflags, for example to prefer an internal registry or a mirrored BCR endpoint.1 - Consumers can steer archive downloads with
--downloader_configor--module_mirrors, which is especially useful in CI or during temporary infrastructure incidents.6,3 --module_mirrors=https://bcr.cloudflaremirrors.comadds a Cloudflare-hosted mirror for the source archives of BCR modules. It covers neither the registry metadata nor files that repository rules download themselves, so for the metadata you still need your own index registry or a written incident playbook.5,6
The local-registry-chain snippet isolates the consumer-side registry knob: its assertion script runs bazel mod graph and bazel build with a file:// registry first and https://bcr.bazel.build configured second. The demo module exists only in the local registry, while the command keeps the public registry as an explicit fallback for other modules.
One practical pattern is to keep a small downloader config ready so Bazel can rewrite known URLs toward internal storage during an outage or controlled migration:3
# .bazel_downloader.cfg
rewrite mirror.bazel.build/(.*) storage.googleapis.com/example_bucket/$1
These knobs provide alternate routes while Bazel is still fetching dependencies. They are not the offline-build mechanism: prefetching, repository-cache reuse, and vendoring belong to 3.1.9 Offline / Air-Gapped Builds, while CI air-gap operations belong to 6.9.2 Air-Gapped Builds.7
Untested fallbacks fail in the incident they were meant for. Rehearse one in a staging CI environment: block the external hosts with firewall rules, then check that builds still succeed through your mirrors, or fail fast with a clear error, and that the runbook steps actually work.5
Keep the concerns separated
It helps to keep three distinct questions separate:
- Can Bazel reach registry metadata at all?
- Are the source archives behind those metadata entries byte-stable and mirrored?
- Do we trust the artifact we downloaded to match the reviewed source?
This article is about the first two. The immutability rules for registry contents themselves are the next topic in 3.1.7 Registry Immutability. The trust/provenance side is improving through BCR attestation work, but that is a security story more than an availability story. The deeper model lives in 6.10.3 Build Provenance and Attestations.8
Provenance is getting better, but it solves a different problem
Recent BCR publishing work can attach provenance attestations to module releases, which helps answer "was this release artifact built from the source I reviewed?"8 That does not remove the need for mirrors, downloader policy, or alternate registry endpoints. Availability and authenticity reinforce each other, but they fail in different ways.
Treat BCR as dependency metadata plus fetch policy, not as artifact storage. Registry failover keeps metadata reachable. Archive mirrors and downloader policy keep source bytes reachable. Lockfiles, prefetching, and vendoring are the separate offline layer in 3.1.9 Offline / Air-Gapped Builds.
Check your understanding · 3 questions
1.BCR's hosted endpoint at bcr.bazel.build is unreachable, but the underlying bazelbuild/bazel-central-registry repository on GitHub is fine. Why does pointing --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/ reliably keep builds going?
Select one answer
2.True or false about BCR infrastructure and archive stability:
Choose True or False for each sentence
3.Match each resilience knob to the failure mode it best mitigates:
Drag each answer onto the matching prompt, or click an answer and then click a prompt
Footnotes
-
Bazel registries — index registry layout,
bazel_registry.jsonmirrors,source.json, BCR role, and--registry↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 -
How GitHub's upgrade broke Bazel builds — unstable GitHub archive checksums,
mirror.bazel.build, and why BCR metadata does not by itself solve archive stability ↩1 ↩2 ↩3 ↩4 ↩5 -
December 2025 Bazel Central Registry Outage — concrete hosted-BCR incident, raw GitHub registry fallback, and downloader-config workaround patterns ↩1 ↩2 ↩3 ↩4
-
Postmortem for *.bazel.build SSL certificate expiry — "Impact", "Background", and "Next steps": what
releases,bcr, andmirror.bazel.buildserve, the shared Google-managed certificate whose renewal failed silently, the 13-hour outage, when BCR access can be skipped, and the recommendation to host internal mirrors for binaries, metadata, and archives ↩1 ↩2 -
Accessing external resources reliably with Bazel — "Mirrors":
--module_mirrorswith the Cloudflare BCR mirror covers registry sources but not the registry itself orrepository_ctxdownloads, the 2022 and 2025mirror.bazel.buildcertificate expiries, own index registry or playbook; "Chaos testing": blocking external hosts in staging CI ↩1 ↩2 ↩3 -
Command line reference —
--downloader_configpolicy file withallow,block, andrewritedirectives, and--module_mirrorssource mirrors that take precedence over registry-provided mirrors ↩1 ↩2 -
Frequently asked questions — offline builds through
bazel fetchprefetching,--nofetch, andbazel vendor↩ -
Securing Bazel's Module Registry — provenance attestations for BCR modules and their role in artifact trust ↩1 ↩2