Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixing mac os yosemite issue "bash: fork: Resource temporarily unavailable"
# see the current limits
$ sysctl -a | grep maxproc
# increase it
$ sudo sysctl -w kern.maxproc=xxxx
$ sudo sysctl -w kern.maxprocperuid=xxx
# run at startup
$ sudo vim /etc/sysctl.conf
kern.maxproc=xxxx
kern.maxprocperuid=xxxx
$ sudo launchctl limit
$ sudo launchctl limit maxproc <maxprocperuid> <maxproc>
$ sudo launchctl limit maxfiles 512 unlimited
# run at startup
$ sudo vim /etc/launchd.conf
limit maxproc <maxprocperuid> <maxproc>
limit maxfiles 512 unlimited
@lucasdavila

This comment has been minimized.

Copy link
Owner Author

@lucasdavila lucasdavila commented Nov 10, 2014

kern.maxproc: 1064 -> 2128
kern.maxprocperuid: 709 -> 1418

@philihp

This comment has been minimized.

Copy link

@philihp philihp commented Feb 8, 2015

Thanks for this!

@tgaff

This comment has been minimized.

Copy link

@tgaff tgaff commented Apr 30, 2015

The changes to /etc/launchd.conf don't appear to work in Yosemite.

After setting the following in launchd.conf

limit maxproc 1418 2128
limit maxfiles 512 unlimited

and rebooting launchctl limit still says:

$ launchctl  limit
    maxproc     709            1064
    maxfiles    256            unlimited

It appears other users have also encountered this issue: http://superuser.com/questions/836883/increasing-yosemite-maxfile-limit-for-application

(Sharing here as this currently rises to the top on google search results for "yosemite forkpty")

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 8, 2015

think

@madrobot

This comment has been minimized.

Copy link

@madrobot madrobot commented Jun 28, 2017

Thank you for this! What are the maximum values that can be set for maxproc and maxprocperuid?

@kinnth

This comment has been minimized.

Copy link

@kinnth kinnth commented Aug 31, 2017

I'm getting this issue right now on 10.12.6 and im on one of the newer and faster mac pros. It seems a little unbelieveable that im hitting this limit. I have firefox with 20 or more tabs and then say 10 other applications open but on my old mac I never hit this limit. I'm following the guide listed here, but could there ever be any issues to the mac if you double your process count i.e could it burn out the process or drain battery massively?

@girishkalele

This comment has been minimized.

Copy link

@girishkalele girishkalele commented Mar 1, 2018

A limit of 1064 processes on a 16 GB 8-core i7 Macbook is extremely low - I couldn't believe it when I first hit this "Cannot fork" issue.

@isomorphisms

This comment has been minimized.

Copy link

@isomorphisms isomorphisms commented Mar 3, 2018

from man 8 sysctl:

 The -w option has been deprecated and is silently ignored.
@isomorphisms

This comment has been minimized.

Copy link

@isomorphisms isomorphisms commented Mar 15, 2018

I also needed sudo sysctl kern.tty.ptmx_max=255 (or 511, or whatever). My default (in El Capitan) was 127. (As a tmux user, I need more than that.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.