This question already has an answer here:

I just updated the Mac OS X to Yosemite, and now some applications do not work (IBM DB2). I know that I need to set the Open Files to 65000, however the command does not work.

Andress-MBP:~ root# ulimit -n 12288
Andress-MBP:~ root# ulimit -n 12289
-sh: ulimit: open files: cannot modify limit: Invalid argument

Why is this happening and how can I correct the problem?

marked as duplicate by Journeyman Geek Jan 25 '17 at 0:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

It seems like there is an entirely different method for changing the open files limit for each version of OS X!

For OS X Sierra (10.12.X) you need to:

1. In Library/LaunchDaemons create a file named limit.maxfiles.plist and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"  
<plist version="1.0">  

2. Change the owner of your new file:

sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist

3. Load these new settings:

sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist

4. Finally, check that the limits are correct:

launchctl limit maxfiles
  • 4
    Looking forward to a new answer for macOS 10.13! :) – NSTJ Feb 21 '17 at 13:57
  • 1
    The process did not work for me until I restarted. Thanks! it really helped a lot – user2773086 Jul 29 '17 at 8:22
  • This gist also says modifying these files is the way to update this open file limit for Sierra – Devin G Rhode Dec 22 '17 at 19:43
  • Restart is necessary for the limits to work (even if step #4 does show the updated values) – trinth Aug 29 at 22:44

I see you asked this question all over.

There is a kernel limit you have to deal with, kern.maxfiles which is the kernel limit and can't be exceeded when setting ulimit.

See the Krypted blog page Maximum Files in Mac OS X for a description on how to manipulate kern.maxifiles using sysctl.

I haven't loaded Yosemite on my Mac yet. The sysctl -w kern.maxfiles=65000 works on Mavericks, which has the same kern.maxfiles=12288 limit by default.

I checked on my VM OS X 10.6.8 and it had the same limit which begs the question of how it was previously working prior to your OS X version.

There's a slide share (DB2 for Mac OS X Installing and setting up DB2 for Mac OS X) showing the recommended limits for using DB2, see Increase System Parameters page 7.

Increase System Parameters

Open /etc/sysctl.conf (or create it if it doesn't already exists) and insert the following settings. These settings increase some settings for shared memory and user limits that DB2 needs in order to work on Mac.

Add the following to /etc/sysctl.conf

It sounds like you lost your /etc/sysctl.conf file when you upgraded.

  • Actually, I installed DB2 long time ago and it worked. Then I updated to Maverick last year, without any problem. And today, I updated to Yosemite and this problem appear. I cannot start my already installed DB2. – AngocA Oct 18 '14 at 1:19
  • Another thing is that my sysctl.conf is identical to the file you put in your post. I created the first time I installed DB2 (one year ago), but I did not touch it for the migration. – AngocA Oct 18 '14 at 1:36
  • The problem was some blankspaces in that file:… – AngocA Nov 12 '14 at 13:26
  • 1
    Trailing spaces, who would have thought. Apple is supposed to have some of the best programmers in the world. – user187561 Nov 12 '14 at 15:53
  • @user187561 sysctl(8) comes from BSD. – Drew Stephens Sep 26 '16 at 14:12

In Mac OS 10.10 it seems the ulimit setting can't exceed the launchctl limit setting.

So you should first run launchctl limit maxfiles in terminal to get the current setting:

launchctl limit maxfiles
maxfiles    256            unlimited 

So in my case the soft limit is 256, the hard limit is unlimited. And then if i want to set the soft limit to 512:

sudo launchctl limit maxfiles 512 unlimited

Detailed usage of launchctl for setting limits can be found here:

  • 'launchctl limit maxfiles 512 unlimited' appears to set my (soft, hard) limits to (512,10240) on Yosemite 10.10.5 on 2015-09-30 – Dave X Sep 30 '15 at 15:33
  • 2
    "launchctl limit maxfiles unlimited unlimited ; launchctl limit maxfiles" indicates that 10240 is the largest limit that may be entered. Using larger numbers silently fails, leaving the setting as before. – Dave X Sep 30 '15 at 15:39

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