“Too many open files” limit/ulimit on Mac OS X

Thomas Jung
Mindful Technology
Published in
1 min readOct 3, 2017

--

Ran into this often enough that I just wanted to summarize the steps I took based on this post to permanently increase the limit of number of open files on my Mac.

Before I started (and after getting the error):

$ ulimit -a
[...]
open files (-n) 256
[...]
max user processes (-u) 709
[...]

Steps To Fix

  • Become root (let’s not argue right now …): $ sudo su — root
  • Create /Library/LaunchDaemons/limit.maxfiles.plist with this content; file will (must) be owned by root, which is important:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>524288</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
  • If you also want the number of allowed processes increased, create
    /Library/LaunchDaemons/limit.maxproc.plist with content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
  • Restart your computer!

After:

$ ulimit -a
[...]
open files (-n) 524288
[...]
max user processes (-u) 2048
[...]

--

--

Thomas Jung
Mindful Technology

Building stuff made of bits and bytes. Cofounder and CTO of DealPoint.io