Some limits cannot be changed by
ulimit, because they only apply to the current shell, therefore
launchctl command should be used to change the limits globally, e.g.
sudo launchctl limit maxfiles 100000 unlimited
Please note that applying these limits in
/etc/launchd.conf (as suggested in other answers) is no longer supported in the recent macOS releases. Although can still use
man launchd.plist) such as per-user or system-wide
plist configuration files as suggested here, there, and over there.
To make these limits persistent, you can use
/etc/sysctl.conf file and add for example:
For changes to take the effect, it requires reboot.
To see the current limits, run:
launchctl limit or
sysctl -a | grep ^kern.max.
See also: How to persist ulimit settings in macOS?