68

While I am connecting to my server I get,

-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable

And I try following commands also, then the result is same.

-bash-4.1$ df -h
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash-4.1$ 
-bash-4.1$ ls -lrth
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Interrupted system call
-bash-4.1$ 
-bash-4.1$ ps -aef | grep `pwd`
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash-4.1$ 

Why this comming ? And how can I resolve it ?

2
  • 3
    Looks like swap being overloaded (/tmp filesystem possibly full)
    – Lambert
    May 22, 2015 at 10:58
  • 2
    ulimit -a, maybe you hit some process limit
    – c4f4t0r
    May 22, 2015 at 13:29

5 Answers 5

40

This could be due to some resource limit, either on the server itself (or) specific to your user account. Limits in your shell could be checked via ulimit -a. Esp check for ulimit -u max user processes, if you have reached max processes, fork is unable to create any new and failing with that error. This could also be due to swap/memory resource issue

27

fork: Resource temporarily unavailable

The error means that the current shell resource is limited (check the limits by ulimit -a). So you can either try in another shell, or increase the resources by using ulimit command which controls over the resources available to the shell and processes it creates on operating system.

To increase the limits, try running:

ulimit -Sn unlimited && ulimit -Sl unlimited

to raise the soft limits to hard one, or:

ulimit -l unlimited
ulimit -n 10240 

to set the maximum size a process to unlimited and the maximum number of open file to 10240.

See: help ulimit for more information.

To make it persistent, add the above settings into your startup rc files (e.g. ~/.bashrc).


You can also use /etc/sysctl.conf (see: man sysctl.conf) to increase the kernel limits, e.g.

kern.maxprocperuid=1000
kern.maxproc=2000
3
  • 2
    When this error occurs, does the "retry" imply that it will attempted repeatedly until resources become available? Jul 15, 2018 at 4:29
  • 2
    @DavidB Or that it did retry, but failed.
    – Kusalananda
    Aug 22, 2019 at 7:40
  • kern.maxprocperuid, kern.maxproc, kernel.maxprocperuid and kernel.maxproc do not exist on Ubuntu. What is the alternative there? May 4, 2020 at 2:06
2

dmesg is your friend. Run this command why a system might have blocked something.

With systemd based systems there are user limits handled there as well. You check the limits with these commands:

systemctl status user-1000.slice
systemctl cat user-1000.slice

1000 is the PID of the user in charge, respective you try to login.

For further information check following page, there you can see how to change or alter the limits for specific or all users:

https://www.suse.com/support/kb/doc/?id=000019044

0

For me, this error was actually caused by a multiline comment not being properly written... For whatever reason, this error would then occur.

Had to change this:

<<comment
# Comment lines
...
comment

# Code
...

to this (just added the quotes around the first comment):

<<'comment'
# Comment lines
...
comment

# Code
...
-4

The problem can also be resolved using following commands:

yum install psmisc
killall -STOP -u user1
killall -KILL -u user1

Here user1 is the user group for which the limit has been exceeded

4
  • 5
    Killing every single process belonging te the user seems a bit heave handed. Also, that yum command probably would not be able to fork either.
    – Kusalananda
    Aug 22, 2019 at 7:47
  • The yum command will be run through root user, assuming that problem has occurred on a different user than root
    – Arun
    Aug 22, 2019 at 8:57
  • 2
    If the shell fails to fork df it would have issues running sudo too.
    – Kusalananda
    Aug 22, 2019 at 8:58
  • 1
    BOFH style. I like it!
    – Matthias
    Nov 17, 2020 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .