solovyov.net

MacOS: too many open files

1 min read · macos, gostatic

Sometimes MacOS gives you an error like this. I tried to fix that by whatever Internet told me: made kern.maxfiles and kern.maxfileperproc values bigger, changed limits in launchctl limit - it did not really help though. Usually the error went away just because some application stopped doing what it was doing.

Lately it became unbearable: I start gostatic in a file watching mode and some file changes triggered execution of an external command (lessc in my case), which caused too many open files. How many is “too many”, dammit! Anyway, I’ve spent 10 minutes on that again and here is the post to prevent searching web again (and maybe it’ll help somebody else as well).

So, solution. I never looked carefully enough at ulimit -n, because it always said unlimited. It seems like a wishful thinking though, and the actual limit is pretty low. So:

ulimit -S -n 4096

did help!

FYI: I’ve spent some time experimenting and established that maximum open files per 1 process is 249 inclusive.

If you like what you read — subscribe to my Twitter, I always post links to new posts there. Or, in case you're an old school person longing for an ancient technology, put a link to my RSS feed in your feed reader (it's actually Atom feed, but who cares).

Other recent posts

Server-Sent Events, but with POST
ngrok for the wicked, or expose your ports comfortably
PostgreSQL collation
History Snapshotting in TwinSpark
Code streaming: hundred ounces of nuances