Docker "failed to solve: rpc error: code = Canceled" in CI
By Kaveh Alemi·Latchkey
The build was cancelled mid-solve. rpc error: code = Canceled means the gRPC call to BuildKit was aborted - usually the job timed out, the runner/builder was torn down, or the buildkitd connection dropped while the build was running.
What this error means
A long-running build stops partway with failed to solve: rpc error: code = Canceled desc = context canceled. It is not a Dockerfile error - the build context was cancelled before it finished.
docker
#14 [build 5/7] RUN go build ./...
#14 CANCELED
ERROR: failed to solve: rpc error: code = Canceled desc = context canceled
Common causes
The CI job hit its time limit
When the surrounding job is cancelled (timeout or manual cancel), buildx receives a cancellation and the in-flight solve is reported as Canceled.
The builder or runner was torn down mid-build
If the docker-container builder or the runner itself goes away during the build, the gRPC stream is cancelled.
buildkitd connection dropped
A dropped connection to buildkitd (crash, network blip) cancels the active solve.
How to fix it
Raise the job timeout and reduce build time
Give the build enough time and cut its duration with caching and parallelism.
Retry a build cancelled by infra, then stabilize the builder
A cancellation from a torn-down builder is retryable; a job-timeout cancellation needs a faster or longer-budgeted build.
How to prevent it
Set a job timeout that comfortably fits the build.
Cache layers so builds finish well inside the time budget.
Keep buildkitd healthy so connections do not drop mid-solve.
Frequently asked questions
What causes ""rpc error: code = Canceled""?
When the surrounding job is cancelled (timeout or manual cancel), buildx receives a cancellation and the in-flight solve is reported as Canceled.
How do I fix "rpc error: code = Canceled"?
Give the build enough time and cut its duration with caching and parallelism.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.