Skip to content
Latchkey

Nx "Daemon process terminated" - Fix Daemon Crashes in CI

The Nx daemon - a background process that caches the project graph - crashed or was killed mid-run, so the connection dropped. On a constrained runner this is usually memory pressure or a stale daemon socket, and it often clears on retry or with the daemon disabled.

What this error means

A command fails with "NX Daemon process terminated and closed the connection". It is intermittent - re-running the job, or disabling the daemon, frequently succeeds with no code change, which points at a transient/resource issue rather than a config bug.

Nx output
NX   Daemon process terminated and closed the connection

Please rerun the command, which will restart the daemon.
If you get this error again, check for memory limits and stale lock files.

Common causes

Daemon killed under memory pressure

On a small runner the daemon process can be OOM-killed while building a large project graph, dropping the connection mid-command.

Stale daemon socket or lock

A leftover socket/lock from a previous run (or a cached .nx/ directory restored between jobs) can leave the daemon in a bad state.

How to fix it

Reset and retry

Clearing the daemon state and rerunning resolves most transient crashes.

Terminal
nx reset
nx run-many -t build

Disable the daemon in CI

CI runs are short-lived, so the daemon’s caching benefit is small. Disabling it removes a whole class of flake.

Terminal
export NX_DAEMON=false
nx affected -t build

Give the runner more memory

  1. If the daemon is being OOM-killed, move the job to a larger runner.
  2. Avoid caching .nx/ across jobs if a stale graph is implicated.
  3. On a self-healing runner, daemon OOM/termination can be retried automatically on a larger instance.

How to prevent it

  • Set NX_DAEMON=false in CI to avoid daemon lifecycle flake.
  • Size runners to fit the project-graph memory footprint of large workspaces.
  • Do not persist .nx/ daemon state across unrelated jobs.

Related guides

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