Increase Open File Descriptor Limits – (Fix Too Many Open Files Errors) Mac OS X 10.14
Mac OS X limits the amount of open files (file descriptors) by default to 256. This sometimes causes certain applications, such as Oracle MySQL and certain Java processes, to show errors like “too many open files”. You can check the current maximum open files limit in Terminal by typing the command below.
launchctl limit maxfiles
This likely outputs: maxfiles 256 (Mac OS X soft limit currently) and unlimited (Mac OS X hard limit currently set).
Change Mac OS File Descriptor Limits Temporarily
sudo launchctl limit maxfiles 64000 524288
This will change the maximum open files to 64000 with a maximum hard limit of 524288. This will only take affect until you log out or reboot your Mac.
Change Mac OS File Descriptor Limits Permanently
- Create a plist file at
/Library/LaunchDaemons/limit.maxfiles.plist
with the following in it below. This file will automatically load after startup and set the max file limits per the Mac OS system.
The limits below are 64000 soft and 524288 hard in the config – feel free to change these.
<?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>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
2. In Terminal, change the owner of the file.
sudo chmod 600 /Library/LaunchDaemons/limit.maxfiles.plist
sudo chown root /Library/LaunchDaemons/limit.maxfiles.plist
- Load the plist file now and future startups.
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
- Test. Reboot your Mac then ensure the limits are set correctly by running the following command in Terminal.
launchctl limit maxfiles
Comments 1
I'm running Transmission under Big Sur but cannot create a file with sudo. Tried nano and touch. Cannot run launchctl with sudo either. Should I try with root?