`ulimit -n` for non-root

Having had this exact same problem, I ultimately found that my bash startup sequence (.bashrc or similar) was doing a ulimit -n 1024; and that caused both the soft and the hard limit to get set; the latter of which prevented any attempt at raising it afterwards, giving rise to the "bash: ulimit: open files: cannot modify limit: Operation not permitted" error.

So, removing that command got the soft and hard limits restored to the apparent system defaults of 256 and unlimited respectively. The latter is what will enable you to ulimit -n <whatever> again.

In your case, assuming the cause is similar and your Library/LaunchDaemons/limit.maxfiles.plist is still in place as listed, I expect that ulimit -Sn and ulimit -Hn will report both to be 200000.


For me on macOS Mojave, I had to set both:

.bash_profile

ulimit -n 65536

.bashrc

ulimit -n 65536

If you only set from profile you can only increase from 256 to 1024.

It’s weird because there is not so much info about this online, I wonder how developers manage without it.