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.
bash: fork: retry: Resource temporarily unavailable
bash: fork: retry: Resource temporarily unavailable
bash: fork: Resource temporarily unavailableCommon 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.
ulimit -u # max user processes
cat /sys/fs/cgroup/pids.max # cgroup pid limit (container)
ps -eLf | wc -l # count threads currently runningReduce concurrency or raise the limit
- Cap the parallelism of the offending tool (worker count,
-j, thread pools). - Raise
ulimit -ufor the step, or the containerpidslimit, 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
pidslimit instead of unlimited, and watch process counts. - Reap zombie/leaked child processes in long-running steps.