Code: Select all
(24)Too many open files: AH00099:
(24)Too many open files: mod_wsgi (pid=931)
We will create 2 PLIST files to load on startup to increase maximum files, descriptors, and processes to give Apache more horsepower.
1. Create a file called limit.maxfiles.plist with:
Code: Select all
<?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. Create a file called limit.maxproc.plist with:
Code: Select all
<?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>12784</string>
<string>14176</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
3. Put both files in
Code: Select all
/Library/LaunchDaemons
4. Make the plists root:wheel so macOS has permission to load them on startup. In Terminal type:
sudo chown -R root:wheel /Library/LaunchDaemons/limit.maxproc.plist
sudo chown -R root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
5. Reboot macOS system.
6. Confirm new limits are in place. In Terminal type: ulimit -a
Code: Select all
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8176
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 4000
-n: file descriptors 64000
Note: It appears macOS Monterey may have a limit of setting a maximum of 4000 processes. In addition, you may need to disable SIP (System Integrity Protection in macOS to allow the higher limits. Follow this guide.
There's one annoying cavet to this. If you use MAMP Pro auto start Apache and MySQL plists LaunchDameon scripts, sometimes those load before your maxproc and maxfile plist files causing Apache to not startup with the new file limits. Your new limits wouldn't take affect until you stop/start Apache again. To get around this, need to figure out how to load the plist's in order. Will follow back up here once determined.