Use Bazel Central Registry mirrors¶
Bazel builds using bzlmod (the default since Bazel 8.0) depend on the Bazel Central Registry (BCR) and on the hosts that serve module source archives. When either is unavailable, as in the December 2025 BCR outage, builds that need to fetch modules fail. Public mirrors let you keep building during such an outage.
A BCR fetch downloads two kinds of files, and each needs its own mirror:
- Registry files:
MODULE.bazel,source.json, andmetadata.jsonfor each module version, served byhttps://bcr.bazel.build. Mirror these with--registry. - Source archives: the module source code that
source.jsonpoints to, usually on GitHub releases ormirror.bazel.build. Mirror these with--module_mirrors.
Bazel verifies every download against hashes stored in the registry and pinned
in MODULE.bazel.lock, so a mirror can't change the contents of your build.
Mirror the registry¶
The BCR is built from the bazelbuild/bazel-central-registry GitHub repository, so you can read registry files straight from GitHub:
Bazel searches registries in the order you list them and uses later registries
only for modules that earlier ones don't provide. Setting --registry also
stops Bazel from using the BCR by default. If you use your own registry too,
list it before the BCR mirror:
common --registry=https://registry.example.com/
common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/
Bazel records registry file URLs in MODULE.bazel.lock. After you change
--registry, run bazel mod deps --lockfile_mode=update and commit the
updated lockfile; otherwise builds with --lockfile_mode=error fail.
Mirror module source archives¶
In Bazel 8.4 and later, --module_mirrors lists URL prefixes that Bazel tries
before a module's own source URLs. Cloudflare runs a public mirror:
Bazel adds the original URL, minus its scheme, to the mirror prefix. For
example, https://github.com/foo/bar/archive/v1.tar.gz becomes
https://bcr.cloudflaremirrors.com/github.com/foo/bar/archive/v1.tar.gz.
Pass several comma-separated URLs to try more than one mirror. In Bazel 8.6 and
later, you can set mirrors for a single registry with
--module_mirrors=<registry>=<mirror>[,<mirror>...].
The Cloudflare mirror serves source archives only. It doesn't mirror the registry files, so use it with the registry mirror above.
Mirror other downloads¶
Some rule sets download tools and other files from mirror.bazel.build
outside of Bzlmod, so --module_mirrors doesn't apply to them. To redirect
those downloads, add a rewrite rule to a downloader config file:
Cloudflare mirrors only part of mirror.bazel.build. For files it lacks, host
copies in your own bucket and rewrite to that bucket instead.
To route all downloads through your EngFlow cluster, see Remote Asset API.
Verify the configuration¶
Fetch all dependencies with an empty output base and no repository cache, so that Bazel downloads every file again: