Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to do something that requires a large number of file descriptors

sudo ulimit -n 12288 is as high as Snow Leopard wants to go; beyond this results in

/usr/bin/ulimit: line 4: ulimit: open files: cannot modify limit: Invalid argument.

I want to raise the number much higher, say 100000. Is it possible?

share|improve this question
This question's answers no longer work in OSX Mavericks. –  Howard Jan 7 '14 at 10:02
Running echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf and restarting works for me in Mavericks. –  ؘؘؘؘ May 30 '14 at 17:40

4 Answers 4

up vote 54 down vote accepted

ulimit only changes the resource limits for the current shell and its children; sudo ulimit creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect). To exceed 12288, you need to adjust the kernel's kern.maxfiles and kern.maxfilesperproc parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit to adjust all of these at once:

sudo launchctl limit maxfiles 1000000 1000000

To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf containing:

limit maxfiles 1000000 1000000

Then you can use ulimit (but without the sudo) to adjust your process limit.

BTW, if this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.

share|improve this answer
That works perfectly, thanks. –  Chris Poole Jun 28 '11 at 11:57
sudo launchctl limit maxfiles 1000000 unlimited Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both. –  Thomas Hunter May 14 '14 at 0:16
Be careful when adding that line to launchd.conf. I think if the number is too small, it can make your computer unusable. For example, I used limit maxfiles 1024 1024 and I had a really hard time changing it back. –  Shawn Oct 12 '14 at 12:25

The following should resolve most solutions (and are listed in order of their hierarchy):

echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf
echo -e 'limit maxfiles 8192 20480\nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf
echo 'ulimit -n 4096' | sudo tee -a /etc/profile


  1. You will need to restart for these changes to take effect.
  2. AFAIK you can no longer set limits to 'unlimited' under OS X
  3. launchctl maxfiles are bounded by sysctl maxfiles, and therefore cannot exceed them
  4. sysctl seems to inherit kern.maxfilesperproc from launchctl maxfiles
  5. ulimit seems to inherit it's 'open files' value from launchctl by default
  6. you can set a custom ulimit within /etc/profile, or ~/.profile ; while this isn't required I've provided an example
  7. Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
share|improve this answer
You saved me, thank you. Only thing I could get to hold the change in max open files –  Stephen Baugh May 19 at 23:52

It seems that OS X Lion will not permit "unlimited" as a value:

% sudo launchctl limit maxfiles 8192 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.

Providing numerical values for both the soft and the hard limit does the job:

% sudo launchctl limit maxfiles 4096 8192
share|improve this answer
If one of the values was unlimited, using -1 as value results in 12288. It's possible to use larger numeric values, e.g. sudo launchctl limit maxfiles 15000 150000. I'm not sure these settings have an effect then, though. –  Daniel Beck Dec 10 '11 at 10:59

On Mavericks its simple. As a regular user:

ulimit -n 8192

You can check the updated settings via

ulimit -a

On my machine:

ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       709
-n: file descriptors                8192
share|improve this answer
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself. –  y3sh Oct 15 '14 at 13:34
sudo should not be used here but this answer is incorrect. Mavericks users should use echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf and then restart their machine –  Kyle Chadha Mar 17 at 22:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.