Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get rid of the pesky "Too many open files in system" limit on OS X 10.7.1. 

Is there a way?

share|improve this question
Do you want to explain more about when this happens? In which circumstances? – slhck Jun 7 '12 at 8:56
@slhck - I have the same problem. The circumstances are basically "at random." I'm a developer, so I'm using my Mac fairly heavily: running one or more databases, a web server, testing tools, one or more browsers, and a music player all at once. Google Chrome seems to be one program that has a lot of files open. – Nathan Long Jun 22 '12 at 18:25
Actually, my "heavy use" wasn't the issue; my settings for the maximum number of open files for the kernal and per-process were far lower than what the defaults should be. – Nathan Long Jun 29 '12 at 20:16
If your read Nathan's comment and wondered why he didn't include any details about the defaults, it's because he spelled it all out in his answer, below. (Nice answer! :) – Olie Jun 13 '13 at 18:06
I'm in the same usage circumstance as Nathan Long, and found restarting Apache was the only step that "solved" the problem. I applied all the below limit increases but they didn't help immediately. I am running command line phpUnit tests > selenium server > firefox > apache > php > mysql all on the same macbook. Used to work fine until I upgraded to mavericks. The error I get is in the webapp being tested, i.e. it's php/apache running out of files, so presumably not controlled by the shell setting. – scipilot Sep 19 '14 at 7:55

According to this helpful article (which I recommend reading):

By default, the maximum number of files that Mac OS X can open is set to 12,288 and the maximum number of files a given process can open is 10,240.

You can check these with:

  • sysctl kern.maxfiles
  • sysctl kern.maxfilesperproc

You can increase the limits (at your own risk) with:

  • sysctl -w kern.maxfiles=20480 (or whatever number you choose)
  • sysctl -w kern.maxfilesperproc=18000 (or whatever number you choose)

To make the change permanent, use sudo to put your settings in /etc/sysctl.conf (which you may have to create), like this:


(Note: a setting in /etc/launchd.conf like limit maxfiles will override whatever you put here.)

Again, from the article:

Once you’ve done this, the kernel itself will have a maximum number of files but the shell might not. And since most processes that will take up this many files are going to be initiated by the shell you’re gonna’ want to increase that.

The command for that is:

ulimit -S -n 2048 # or whatever number you choose

That change is also temporary; it only lasts for the current shell session. You can add it to your shell configuration file (.bashrc, .zshrc or whatever) if you want it to run every time you open a shell.

share|improve this answer
what limit applies to processes launched by clicking icons in the launch area? And how to change that limit? When you say "shell", I'm assuming you mean an interactive terminal shell. – Cheeso Aug 15 '12 at 0:48
@Cheeso - I think that the overall system limit (sysctl) or the launchd limit, whichever is lower, controls that. – Nathan Long Dec 14 '12 at 20:39
creating an /etc/launchd.conf with contents limit maxfiles 1000000 1000000 worked great for me! (OSX 10.8.2 here) – Zugwalt Feb 1 '13 at 19:26
@Zugwalt, what is the actual text you put inside the /etc/lunchd.conf? You can use ticks ( ` ) to escape code. – Xeoncross Jun 28 '14 at 0:59
I put kern.maxfiles=65000 kern.maxfilesperproc=65000 in /etc/sysctl.conf and rebooted. kern.maxfiles was ignored and stayed the default but kern.maxfilesperproc was set to 65000. I have no /etc/launchd.conf so what's up with that? – pferrel Nov 13 '14 at 0:47

You will need to increase your ulimit settings - it's pretty low on OS X these days - 256 by default. Add ulimit -n 4096 or similar to your ~/.profile or equivalent and that will solve it in your local environment. Run ulimit -a to check your current levels

To see the system settings, run this:

launchctl limit maxfiles

It is set quite a bit higher in Lion (10240) on a per process basis than it used to be. But if you are still hitting it there then you can set it higher using the same command with the desired levels. To make the changes permanent /etc/launchd.conf is where you need to add the relevant lines.

share|improve this answer
256? It's 2560 file descriptors for me and I've never changed it. The limit is 266 processes (c.f. ulimit -a). – slhck Jun 22 '12 at 18:55
@slhck it says open files (-n) 256 for me too, not 2560 – Erik Aigner May 25 '13 at 10:43
Same for me, 256 files on MacOS X Maverick – Climbatize Aug 9 '14 at 6:44
256 on OS X Yosemite as well – Alexander May 28 '15 at 9:52
256 on El Capitan, too. – TMN Apr 28 at 10:53

Folks, on Mavericks 10.9.4

ulimit -n 2048 works fine. You may need to launch a new login session.

share|improve this answer

You must log in to answer this question.

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