Skip to content
Latchkey

CI "fork: retry: Resource temporarily unavailable" - Fix in CI

The shell tried to fork() a new process and the kernel refused with EAGAIN. Either the runner hit a limit on the number of processes/threads, or it had no memory to back a new process.

What this error means

Bash repeatedly prints fork: retry: Resource temporarily unavailable and eventually fork: Resource temporarily unavailable. Commands fail to start because no new process can be created. It often cascades - once forking fails, almost everything fails.

CI log
bash: fork: retry: Resource temporarily unavailable
bash: fork: retry: Resource temporarily unavailable
bash: fork: Resource temporarily unavailable

Common causes

The process / thread limit (RLIMIT_NPROC) was hit

A build that spawns thousands of threads or leaks processes reaches the per-user ulimit -u or the cgroup pids.max. The kernel then refuses new forks with EAGAIN.

Out of memory for a new process

Forking needs memory for the new process’s page tables and stack. Under heavy memory pressure the allocation fails and fork() returns EAGAIN.

How to fix it

Inspect process and pid limits

See how many processes exist and what the limits are.

Terminal
ulimit -u                       # max user processes
cat /sys/fs/cgroup/pids.max     # cgroup pid limit (container)
ps -eLf | wc -l                 # count threads currently running

Reduce concurrency or raise the limit

  1. Cap the parallelism of the offending tool (worker count, -j, thread pools).
  2. Raise ulimit -u for the step, or the container pids limit, if the work genuinely needs more.
  3. Fix any process/thread leak that grows unboundedly during the job.

How to prevent it

  • Bound parallel workers and thread pools to the runner’s capacity.
  • Set a sane pids limit instead of unlimited, and watch process counts.
  • Reap zombie/leaked child processes in long-running steps.

Frequently asked questions

What causes ""fork: retry: Resource temporarily unavailable""?
A build that spawns thousands of threads or leaks processes reaches the per-user ulimit -u or the cgroup pids.max. The kernel then refuses new forks with EAGAIN.
How do I fix "fork: retry: Resource temporarily unavailable"?
See how many processes exist and what the limits are.
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.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card