Builds and cron jobs on a server start failing with "fork: retry: Resource temporarily unavailable" while memory and CPU are fine.

IntermediateTroubleshootingDisk, memory and CPU
Answer

Likely causes → The process or thread limit was reached: the user's ulimit -u, systemd's TasksMax for the service, the container's pids.max, or the global kernel.pid_max. A thread leak or a fork bomb in a script is usually behind it.

Diagnose →

ps -eLf | wc -l                              # total threads
ps -eLf | awk '{print $1}' | sort | uniq -c | sort -nr | head
ulimit -u
systemctl show myapp -p TasksMax -p TasksCurrent
cat /sys/fs/cgroup/pids.max /sys/fs/cgroup/pids.current 2>/dev/null

Fix → Kill the leaking process, then raise the limit if the workload genuinely needs more (TasksMax=8192 in the unit, LimitNPROC or /etc/security/limits.d/). Fix the thread leak in the app.

Prevent → Set sensible PID limits per container (kubelet podPidsLimit) so one bad pod can't exhaust the node, and alert on thread count growth.

All Real-World Interview questions Roadmap: Interview readiness

More on Disk, memory and CPU