Deversus Software Inc.

Mac OS 10.6.5 + apachectl: /usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

by Mike Walsh on November 12, 2010

After upgrading to Mac OS 10.6.5 this morning while working on Quote Manager, I went to restart apache via the “sudo apachectl restart” command and was presented with an obscure error message:


/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

Since apachectl was working fine 5 minutes before I updated to Mac OS 10.6.5, I figured the two were related. After a quick dig into what the update entailed, I found that Apple updated to Apache 2.2.15, which patched a number of vulnerabilities (http://support.apple.com/kb/HT4435). It turned out that one of those changes broke the apachectl script. Referring to line 82 of apachectl, the shell script was referring to the ULIMIT_MAX_FILES variable, which was set to:


ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"

Changing the line as follows fixed the problem:


ULIMIT_MAX_FILES=""

{ 69 comments… read them below or add one }

Vinny November 12, 2010 at 2:27 pm

Excellent info! Really saved lots of digging.

Reply

Chris November 13, 2010 at 1:38 am

Thanks!

Reply

Rodrigo November 13, 2010 at 3:00 pm

Tanks !!!

Problem solved!

Reply

Barry Carlyon November 15, 2010 at 1:28 am

Ran into this problem this morning.

One google search later! Fixed :-)

Many thanks

Reply

Kim November 15, 2010 at 3:25 pm

Great find! Thanks!

Reply

ben koonse November 17, 2010 at 4:04 pm

thank you.. nice catch.. i was about to start banging my head against a blunt object

Reply

Gary November 17, 2010 at 11:49 pm

Thanks, works like a charm!

Reply

Emanuele November 18, 2010 at 9:55 am

Thank you. Your help is greatly appreciated!!

Reply

Jason November 19, 2010 at 12:06 am

Thanks a ton! I just noticed this too.

Reply

Aaron Vegh November 19, 2010 at 5:24 am

Thanks for this. In my copy of apachectl, it’s line 64, not 82.

Cheers,
Aaron

Reply

Ahmed Dirie November 19, 2010 at 11:23 am

I just updated and have been scratching my head on this for the past 15 minutes. Googled the issue and came across your link. You guys are life savers!

Thanks.

Reply

Mike November 20, 2010 at 4:40 pm

Thanks. You need a tip jar :)

Reply

deptz November 21, 2010 at 6:07 pm

thanks!

Reply

Clauspauli November 22, 2010 at 1:23 am

Thanks

Reply

g. alves November 22, 2010 at 11:11 am

Thanks! I noticed that error popping up suddenly in the last couple days when I started up apache, and I was dreading tracking it down.

Reply

patcon November 22, 2010 at 10:17 pm

Just like everyone else is saying: Thanks! Thought it was something I’d done. Wish I’d googled sooner :)

Reply

patcon November 22, 2010 at 10:19 pm

Oh, and pssssst… adopt drupal! ;)

Reply

Mike Walsh November 23, 2010 at 10:25 am

@patcon I hear Drupal lowers the average developer’s lifespan by 5 years :P

Reply

Steve November 23, 2010 at 10:28 am

Just an FYI for those who are trying to fix this, the error is reported on line 82 but the argument is set on line 64

Reply

Elisa Schaeffer November 23, 2010 at 1:18 pm

Tons of hugs and kisses. You saved me a lot of WTF with this post <3 Shame on Apple for breaking our websites :\

Reply

you November 23, 2010 at 5:39 pm

Thanks, Apple!

But mostly, thanks to Mike Walsh.

Reply

Greg November 24, 2010 at 7:47 pm

Thanks for that. Never like obscure messages like this. Saved a lot of hunting around.

Reply

Josh The Geek November 27, 2010 at 6:02 am

Thanks! What is ‘ulimit’ anyways?

Reply

Daniel Searles November 27, 2010 at 1:10 pm

Thank you for the quick fix.

Reply

Marco November 27, 2010 at 1:34 pm

Thanks a lot! :)

Reply

Lisa B November 27, 2010 at 2:09 pm

thank you! problem solved.

Reply

Uğur Özyılmazel November 28, 2010 at 7:44 am

Thanks. Problem solved… due to this issue, i examined the apachectl file (8

Reply

Donna November 29, 2010 at 4:25 pm

I owe you a cuppa coffee … you just save me from some major head-banging. Thanks!!!

Reply

sikko November 30, 2010 at 4:20 am

worked for me as well.

Thanks mate

Reply

Dae November 30, 2010 at 4:25 am

Worked, thank you.

Reply

James November 30, 2010 at 5:22 am

Rock on. Thanks.

Reply

Patrick November 30, 2010 at 6:21 am

Thanks alot!

Reply

Christian Verkerk November 30, 2010 at 7:28 am

Strange that Apple didn’t fixed this correctly, is there a reason for this?

Reply

Sarah November 30, 2010 at 10:29 am

THANKS! And thanks for ranking high on Google, it’s always awesome when the first fix attempt actually works.

Reply

Michael Curry November 30, 2010 at 7:39 pm

Thank you! Not only helpful, but the post is concise with option of reading more.
Perfection my friend. Perfection.

Reply

Ben December 4, 2010 at 1:39 pm

finally an answer
thanks a million !

Reply

volv December 6, 2010 at 8:33 am

Thanks :-)
Had the same problem…
Worked like a charm

Reply

ken December 8, 2010 at 8:54 am

let me add my thanks to this post. Thank you for taking the time to describe your fix, it really helps the community.

Reply

Eliot December 8, 2010 at 11:36 am

Still broke for me…I have ULIMIT_MAX_FILES=”" in my apachectl file and still getting that error. Set it back to the values you showed and still same error message. Any ideas?

Reply

Matt Gibson December 8, 2010 at 3:16 pm

I _knew_ I hadn’t broken anything :) Thanks for going through the pain of finding this first…

Reply

Skylar Saveland December 11, 2010 at 9:32 am

woot; thanks so much.

Reply

haqu December 13, 2010 at 11:35 pm

thanks!

Reply

Seigo December 17, 2010 at 9:46 pm

thank you. Problem solved.

Reply

Daniela December 29, 2010 at 5:15 pm

Thanks!!!!
Don’t even want to start thinking about how long this would have taken me to sort out :)

Reply

Tom December 30, 2010 at 7:02 am

Nice work!

Reply

Rob Ray December 31, 2010 at 8:07 pm

thanks for the info!

Reply

Joost January 2, 2011 at 8:36 pm

You really helped me out here :)

thnx!!!!

Reply

Gwyneth Llewelyn January 7, 2011 at 6:05 am

Wow, well spotted! Excellent one, it works flawlessly to me. This is worth noticing Apple about, so that they fix it on 10.6.7.

Good job!

Reply

Rosie January 7, 2011 at 12:37 pm

Thank you this has been driving me mad!

Reply

jose January 12, 2011 at 8:38 am

simply brilliant! Thanks

Reply

Henrik Cederblad January 21, 2011 at 6:16 pm

Thanks, works a treat.

Although, I’m not entirely happy changing things that I don’t grok. So, does anyone know what this “ulimit” thing does, and what are the potential risks changing this (if any)?

Reply

superfunkomatic January 22, 2011 at 8:25 am

Many thanx. Simple thing that I would have never known on my own.

Reply

Alvin Crespo January 25, 2011 at 2:16 pm

I know this is going to sound like a noob question, but honestly I havent worked with Apache so much lately and don’t know where I can edit that action?

Reply

Matt Strange February 2, 2011 at 2:32 pm

Like everybody else says… “Thanks!”

Reply

Landon February 5, 2011 at 10:55 am

FYI, if you’ve compiled apache from source (or are otherwise not using the pre-compiled Mac version), the update might have caused “apachectl” to run the wrong version. I ran “whereis apachectl” and found that is was located at /usr/sbin/apachectl, rather than /usr/local/apache2/bin/apachectl.

Renaming the sbin version should do the trick.

-Landon

Reply

Kevin March 4, 2011 at 1:54 pm

Hi Landon,
I am having the same problem as you. I have been able to open usr/sbin/apachectl without problem, but how do you move or rename that file to be under the path you describe. Under apache2 I don’t see a bin. Thanks for your time and help,
Kevin

Reply

Alyda Gilmore February 12, 2011 at 1:57 pm

Wish all fixes were this easy! Thanks a bunch!

Reply

EEEscalona February 21, 2011 at 7:37 pm

Thanks a bunch. really appreciate it.

Reply

James March 8, 2011 at 2:59 pm

sorry, im a lil new to terminal.. how do i change ULIMIT_MAX_FILES=\\ ??

Reply

Clement BEAUFILS March 16, 2011 at 2:40 am

I had the same error but in a different context.

I had MAMP installed and MAMP Apache won’t start. So I tried to start it using /Application/Mamp/bin/start.sh

And I get the « apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument » message.

When I looked in the MAMP apachectl file, the ULIMIT_MAX_FILES variable was at line 64. I tried to comment it but (as I planned).

So I found the apachectl file in /usr/bin/. The ULIMIT_MAX_FILES was at line 82 like in the error statement. So I commented it and made a “sudo apachectl stop”.

I can now launch my MAMP apache without conflicts !

Hope it helps.

Enjoy

Reply

raffy April 5, 2011 at 1:00 pm

cool. Thanks a lot. it was really helpful.

Raffy

Reply

Prodis a.k.a. Fernando Hamasaki de Amorim April 8, 2011 at 5:54 pm

Thanks.

Reply

Jon Bird April 23, 2011 at 9:38 pm

Awesome! Those are some helpful and clear instructions. I just hashed out the original line and wrote what you had recommended below, just in case there was a problem.

Reply

SGL April 28, 2011 at 5:35 am

I did modify the file /usr/sbin/apachectl at the begining of the week, everything went fine. Since a system restart the file is back to its original version (december 8th). Anyone has seen this?

I’m at 10.5.8

Reply

Jake A. Smith May 10, 2011 at 2:09 pm

Ha! And I thought I forgot how the hell this stuff worked on my six month break. Thanks a ton!

Reply

Andrew June 27, 2011 at 8:59 am

I’m running 10.6.7 and it looks like this has been fixed.

Reply

Tristan Pipo July 9, 2011 at 11:17 pm

Thank you so much for this post. Was very helpful in getting my old PowerBook G4 to function as a webserver.

Reply

Vipzen July 28, 2012 at 2:34 pm

Thank you!

Reply

Gautam Prashant September 29, 2012 at 7:52 pm

Thanks a lot.. that solved my problem in a second :)

Reply

Leave a Comment

 

{ 10 trackbacks }

Previous post:

Next post: