How to Fix ‘Resource Temporarily Unavailable’ (EAGAIN) in Linux

Executing a shell command, spawning background worker threads, running automated test suites, or logging in via SSH only to receive the terminal error bash: fork: retry: Resource temporarily unavailable or encountering system calls aborting with errno 11 (EAGAIN: Resource temporarily unavailable) indicates that the Linux kernel has refused an operating system request. In POSIX operating systems, this error is returned when an operation cannot be completed immediately because a system-wide or per-user resource ceiling has been reached—most commonly the maximum number of allowed concurrent processes (nproc), open file descriptors (nofile), inotify watches, or allocated systemd thread quotas. This technical guide explains how Linux enforces process and resource quotas and details step-by-step methods to identify the bottleneck and expand capacity safely.

Understanding What Triggers EAGAIN in Linux

The Linux kernel raises the EAGAIN error (which shares the numerical error code with EWOULDBLOCK) under distinct resource constraint scenarios:

  • Process and Thread Limit Exhaustion (nproc): When a user launches a new process via fork() or clone(), the kernel checks the user current process count against the configured max user processes limit. If reached, fork fails immediately.
  • File Descriptor Exhaustion (nofile): An application attempts to open an additional file handle, network socket, or pipe after hitting the process ulimit -n ceiling.
  • Systemd DefaultTasksMax Saturation: Modern systemd distributions enforce a strict TasksMax slice quota on user sessions and services. When a service (like Docker, Redis, or Webpack) exceeds this thread ceiling, spawn requests abort.
  • Non-Blocking I/O Polling: In non-blocking network socket programming, reading an empty socket buffer returns EAGAIN, indicating that data is not yet available and the caller should retry.
  • Exhausted inotify Watch Limits: Development tooling (such as Node.js, Vite, or IDE file watchers) consuming all available kernel max_user_watches slots.

Method 1: Inspect Current User Limits via ulimit

Determining your active session resource constraints helps pinpoint which threshold was exceeded.

  1. Open your Linux terminal and query all active limits:
    ulimit -a
  2. Pay close attention to two critical values:
    • max user processes (-u): The maximum concurrent processes and threads your user ID can own.
    • open files (-n): The maximum simultaneous file descriptors permitted.
  3. Check how many processes your current user is currently executing:
    ps -u $(whoami) -U $(whoami) -H | wc -l
  4. If the running count approaches or matches ulimit -u, runaway processes or fork bombs are consuming your thread budget.

Method 2: Terminate Runaway Processes and Rogue Threads

Locating and killing zombie or looped processes restores immediate capacity.

  1. List the top process consumers for your user account:
    ps -u $(whoami) -eo pid,ppid,%cpu,%mem,comm --sort=-%cpu | head -n 15
  2. Look for repeated instances of compilers, test runners, or runaway Python/Node scripts that failed to terminate.
  3. Kill rogue process trees cleanly using kill or pkill:
    pkill -f process_name
  4. Verify that your active process count decreases immediately.

Method 3: Increase User Limits in limits.conf

Permanently raising the user process ceiling allows high-concurrency workloads to operate without hitting fork barriers.

  1. Open the PAM limits configuration file with root privileges:
    sudo nano /etc/security/limits.conf
  2. Scroll to the end of the file and append custom soft and hard limits for your target user (or all users using *):
    *          soft    nproc          65535
    *          hard    nproc          65535
    *          soft    nofile         65535
    *          hard    nofile         65535
  3. Save the file (Ctrl + O, then Ctrl + X in nano).
  4. Ensure PAM limits are applied to user sessions by verifying that session required pam_limits.so exists inside /etc/pam.d/common-session.
  5. Log out of your terminal and log back in to apply the updated limits.

Method 4: Adjust Systemd TasksMax Quotas

If your system utilizes systemd, service-level thread caps can block execution even if PAM limits are relaxed.

  1. Check the global systemd task quota:
    systemctl show --property DefaultTasksMax
  2. To raise the ceiling for all system services, edit /etc/systemd/system.conf:
    sudo nano /etc/systemd/system.conf
  3. Uncomment and increase the DefaultTasksMax directive:
    DefaultTasksMax=65535
  4. For a specific systemd service (e.g., myapp.service), configure an override:
    sudo systemctl edit myapp.service
    and insert:
    [Service]
    TasksMax=infinity
  5. Reload the systemd daemon:
    sudo systemctl daemon-reload

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.