Increasing the file descriptor limit on MacOS


When working on my mac with many applications opened I sometimes came across this kind of errors:

Too many open files in system

If I was lucky only one specific application refused to work properly. But occasionally the whole system would become unresponsive and even decline to kill processes.

This command revealed the problem:

$ launchctl limit maxfiles
	maxfiles    256          Unlimited

It turned out that apple had set the limit of open file descriptors to an unreasonably low value.

After trying out many solutions of which some did not work at all or at most temporarilly I found this solution which seems to be permanent and at least works under Catalina:

$ cat /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "">
  <plist version="1.0">
        <true />

Load service:

$ launchctl load /Library/LaunchDaemons/limit.maxfiles.plist

After this step a reboot is required.

ā€“ reboot ā€“

$ launchctl limit maxfiles
	maxfiles    65536          65536

After every change the service has to be unloaded and loaded again:

$ launchctl unload /Library/LaunchDaemons/limit.maxfiles.plist
$ launchctl load /Library/LaunchDaemons/limit.maxfiles.plist