Skip to content
Latchkey

buildx "failed to solve: ... ResourceExhausted: grpc: received message larger than max" in CI

buildx and buildkitd exchange build data over gRPC, which caps individual message sizes. A very large layer, context, or cache record can exceed that cap and the daemon returns ResourceExhausted, aborting the build.

What this error means

A build fails with "failed to solve: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (NNN vs. 16777216)".

buildx
ERROR: failed to solve: rpc error: code = ResourceExhausted desc =
grpc: received message larger than max (18874368 vs. 16777216)

Common causes

A huge file or layer in the build

A multi-megabyte single file (a large binary or dataset baked into a layer) pushes a gRPC message past the default 16 MB limit.

An oversized build context streamed at once

A bloated context with large artifacts that should be ignored inflates the transfer beyond the cap.

How to fix it

Shrink the context and large layers

  1. Add large build-time-only artifacts to .dockerignore.
  2. Fetch big data at runtime or via a volume instead of baking it into a layer.
  3. Split a giant single-file COPY into smaller pieces where possible.
.dockerignore
# .dockerignore
*.tar.gz
datasets/
node_modules/

Recreate the builder to clear oversized state

A bloated cache record can trigger this; recreate the builder so the build starts clean.

Terminal
docker buildx rm mybuilder || true
docker buildx create --name mybuilder --use

How to prevent it

  • Keep the build context lean with .dockerignore.
  • Avoid baking large datasets into image layers.
  • Pull big artifacts at runtime rather than build time.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →