Skip to content
Latchkey

Earthly "could not connect to buildkitd" in CI

Earthly runs all builds inside a buildkitd container it starts through Docker. If the CI job has no Docker daemon, or the container cannot get the privileges buildkitd needs, Earthly cannot connect and fails before building.

What this error means

earthly fails early with "Error: ... could not connect to buildkitd" or "failed to start buildkit: ... Cannot connect to the Docker daemon". Nothing has built yet.

earthly
Error: could not connect to buildkitd: buildkitd did not start within the timeout
failed to start buildkit daemon: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Common causes

No Docker daemon in the CI job

Earthly launches buildkitd via Docker. A job without a Docker daemon (no DinD service and no host socket) has nothing to start it.

buildkitd cannot get the privileges it needs

BuildKit needs elevated privileges. An unprivileged container or a restricted runtime blocks the daemon from starting.

How to fix it

Provide Docker in the job

  1. Add a Docker daemon: use a runner with Docker, or a docker:dind service.
  2. Confirm docker info succeeds in a step before Earthly runs.
  3. Let Earthly start buildkitd once Docker is reachable.
.github/workflows/ci.yml
- run: docker info
- run: earthly +build

Run in a privileged DinD service

When using docker:dind, run it privileged so buildkitd can start.

.gitlab-ci.yml
services:
  docker:
    image: docker:dind
    options: --privileged

How to prevent it

  • Use a runner image that includes a working Docker daemon.
  • Verify docker info before invoking Earthly.
  • Grant the privileges buildkitd requires when running in DinD.

Related guides

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