Fixing “fork failed: Resource temporarily unavailable” on Linux
This blog post talks about how you can fix the error “fork failed: Resource temporarily unavailable” on Linux.
What this message means
This message typically means that the operating system has limited your ability to “fork”. This typically will stop you creating new threads or processes on Linux.
This issue can occur when the ulimit settings have been set too low. Some server management tools such as CPanel will limit processes and this can stop you logging into your server.
To resolve this you will need to log in with an unlimited account, typically root, to modify some of the settings.
Fixing “fork failed: Resource temporarily unavailable”
To fix this we are going to need to change some of the default ulimit settings.
To do this we need to find and modify any ulimit settings that may be limiting your user. You are looking for lines that look like this or similar:
ulimit -n 100 -u 35
This command limits the number of open files descriptors to 100 and the number of processes to 35. If you are seeing “fork failed” you will want to increase these numbers.
Here is a list of the following places this might be set, you will want to review all of these files to see where the limit might be set:
/etc/bashrc
/etc/profile
Some people will customise their single server with -n and -u values of 64000 as this means they should not hit any limits.\
You may want to have a play around with limits, especially if the server is shared as you may not want one using monopolising the server.