I have heard

sudo launchctl limit maxfiles 64000 unlimited


if sudo cat $conf | command rg kern.maxfiles ; then
  ecerr "kern.maxfiles is already set in $conf"
  sudo echo 'kern.maxfiles=40480
kern.maxfilesperproc=28000' >> "$conf"

For previous versions of macOS, but none of these work in Big Sur.

4 Answers 4


/etc/sysctl.conf is no longer supported with Big Sur. To make persistent changes systctl can be issued on boot time using a launch daemon in /Library/LaunchDaemons/com.startup.sysctl.plist

<?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">

and install it with

chown root:wheel /Library/LaunchDaemons/com.startup.sysctl.plist
launchctl load /Library/LaunchDaemons/com.startup.sysctl.plist
  • What security settings need to be flipped to allow writing into ` /Library/LaunchDaemons/` directory? It seems to be protected by Big Sur.
    – Gunnar
    Jun 23, 2021 at 15:10
  • I was using a terminal session as root and a curses-based text editor Jun 24, 2021 at 12:15

I have used the following technique with success on Big Sur v11.6

So it seems that there are multiple settings at play here.

The numbers returned by ulimit -Sn and ulimit -Hn for soft and hard per process limits.

The the numbers returned by launchctl limit maxfiles the first of which is a soft per process limit and the second a hard per process limit.

Then the results of sysctl -a | grep maxfiles which shows kern.maxfiles and kern.maxfilesperproc where kern.maxfiles should be the hard limit for all processes and kern.maxfilesperproc should be the hard limit for a single process.

It seems I can permanently set all of these by adding a file at /Library/LaunchDaemons/limit.maxfiles.plist

with the following content, where 524288 corresponds to the soft limit and 16777216 to the hard limit.

<?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">

In order for the file to take effect you need to ensure that it's owned by root has group wheel.

sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist

You also need to load the daemon.

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

And finally to have this affect the output of ulimit -Sn and ulimit -Hn i needed to restart my machine.

Note: It seems like a mistake that setting a per process soft and hard limit via launchctl affects the kernel max per proc and max file limits, but that is what happens, so I've just chosen values large enough that I think its unlikely I will run into any trouble with them.

  • 1
    Unfortunately this solution doesn't work anymore since macOS 13.4. launchctl is no longer allowed to run as admin, without disabling SIP.
    – TimTwoToes
    Aug 22, 2023 at 9:50
  • Any updates for 13.4 or newer?
    – krizajb
    Jan 4 at 23:13


sudo sysctl kern.maxfiles=64000 kern.maxfilesperproc=28000

Unfortunately it will not persist over reboots. Adding these to /etc/sysctl.conf does not appear to work in Big Sur.

To see your current settings use:

sysctl -a | grep maxfiles

I found this step works for me on Big Sur:

Enable server performance mode as describe below (don't forget to reboot) https://support.apple.com/en-us/HT202528

Then this:

sudo launchctl limit maxfiles 9000000 9999999    

And finally this (pay attention NOT to use sudo here):

ulimit -Sn 9000000

PS: Unfortunately the last two commands are not persist reboot, so they need to be done every time needed, or to include it on the script. Alternatively to add it at ~/.zshrc file on your Big Sur home directory.

  • 1
    (ulimit is a shell bultin, so using sudo with it is meaningless.)
    – HappyFace
    Jun 23, 2021 at 12:19
  • You're right @HappyFace :) Thank you for the correction... I've remove the sudo and in-fact it was not necessary and wrong in the first place.
    – Alex Yang
    Jun 23, 2021 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .