bash: fork: retry: Resource temporarily unavailable

This is commonly caused by running out of file descriptors.

There are different file descriptor limits.

There is the systems total file descriptor limit, what do you get from the command:
sysctl fs.file-nr

From this command you will get 3 numbers. First is the number of used file descriptor the second is the number of allocated but not used file descriptor and the last is the system max file descriptor. If either of the first two numbers are new otr at the third you need to increase the number of file descriptors for the system of find out what is consuming them.

If the total of the used system file descriptors is not near the max it may be a user limit.

To find out what a users file descriptor limit is run the commands:
sudo su – UID
ulimit -Hn

Replace UID with the user ID is the user you want to check, or if you are already logged in as that user just run the ulimit command.

To find out how many file descripters are in use by a user run the command:
lsof -u UID 2>/dev/null | wc -l

So now if you are having a system file descriptor limit issue you will need to edit your /etc/sysctl.conf file and add, or modify it it already exists, a line with fs.file-max and set it to a value large enough to deal with the number of file descriptors you need and reboot.

The line would look somehting like:
fs.file-max = 204708

If it is a individual users file descriptor limit then you will have to update the users limits in the /etc/security/limits.conf file with an entry like:
UID soft nofile 4096
UID hard nofile 10240

Once again you will have to replace UID with the user ID of the account with the issue.

Another possibility is too many threads. We just ran into this error message when running a test harness against an app that uses a thread pool. We used

watch -n 5 -d “ps -eL | wc -l”

to watch the ongoing count of Linux native threads running within the given Java process ID. After this hit about 1,000 (for us–YMMV), we started getting the error message you mention.

Visit Us On TwitterVisit Us On GooglePlusVisit Us On Linkedin

Hi, guest!