CI "fork: retry: Resource temporarily unavailable" - Fix in CI
By Kaveh Alemi·Latchkey
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.
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
Cap the parallelism of the offending tool (worker count, -j, thread pools).
Raise ulimit -u for the step, or the container pids limit, if the work genuinely needs more.
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 CI "fork: retry: resource temporarily unavailable"?
There are 2 common causes: the process / thread limit (rlimit_nproc) was hit and out of memory for a new process. A build that spawns thousands of threads or leaks processes reaches the per-user ulimit -u or the cgroup pids.max.
How do I fix CI "fork: retry: resource temporarily unavailable"?
There are 2 fixes depending on which cause you have: inspect process and pid limits and reduce concurrency or raise the limit. Work through them in order, since the first is the most common.
What does CI "fork: retry: resource temporarily unavailable" actually mean?
Bash repeatedly prints fork: retry: Resource temporarily unavailable and eventually fork: Resource temporarily unavailable.
How do I stop CI "fork: retry: resource temporarily unavailable" happening again?
Bound parallel workers and thread pools to the runner’s capacity. The prevention section lists 3 changes that keep it from recurring.
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.