Increase Open File Descriptor Limits – (Fix Too Many Open Files Errors) Mac OS X 10.14

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).

 

Mac os x file descriptor limit

 

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

 

  1. 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

 

  1. Load the plist file now and future startups.
 

sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist

 

  1. Test. Reboot your Mac then ensure the limits are set correctly by running the following command in Terminal.
 

launchctl limit maxfiles

Related Posts

 

Comments 1

Guest - Amer Neely on Thursday, 21 January 2021 22:25

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?

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?
Thursday, 12 December 2024