Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The server is running fine -- or at least it seems to -- but there's always the following error:

apache2/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)

It happens with Apache 2.2.22-9 on Debian Wheezy.

# apache2ctl configtest

/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
Syntax OK

# service apache2 reload

[....] Reloading web server config: apache2/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
. ok

# service apache2 restart

[....] Restarting web server: apache2/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
... waiting /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
. ok

# service apache2 status

Apache2 is running (pid 32045).

share|improve this question
Have a look at what you have in /etc/security/limits.conf and /etc/security/limits.d. It seems that you have APACHE_ULIMIT_MAX_FILES (see it in /usr/sbin/apache2ctl) variable set to something larger than the limit in that files. – HUB Aug 6 '12 at 9:44

2 Answers 2

The problem stems from /usr/sbin/apache2ctl (on Debian). Check it out:

~$ grep ULIMIT /usr/sbin/apache2ctl
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then

Here it is setting the number of open files allowed to 8192. Or trying to and failing, in your case.

So to avoid getting an error when apache2ctl does that, adjust your system's settings in the /etc/security/limits.conf file by adding these two lines:

*               soft    nofile          8192
*               hard    nofile          8192

I didn't increase it to more than necessary (8192) because I don't know what else it will impact. However this gets rid of the warning.

Not sure if you will need to reboot your system after that, because there is a dynamic element to the ulimits which I am not familiar with. However you can test easily enough to find out what your current ulimit num of files is:

ulimit -n

You might want to read where I found it: stackoverflow - setting ulimit

share|improve this answer
How would I do the reverse and reduce the Apache limit? – Elric Nov 2 at 13:05
Seeing that the script I posted in the answer is direct out of the apache2ctl script which is installed by apache, then you will have to go to that script file and change it, assuming you have the access right and assuming you're willing to repeat the action with every Apache upgrade. – Adam Nov 2 at 15:23

This might help:-


sudo service apache2 restart # no errors
service apache2 restart      # errors
share|improve this answer
Thanks, I already saw that but it doesn't help. Using sudo or not doesn't change anything, I have the same error. – Pascal Polleunus Aug 26 '12 at 15:00
Worked for me! Totally forgot sudo. – ThomasReggi Nov 15 '12 at 16:19
+1 magic sudo always does the trick – bicycle Sep 11 '13 at 0:06
even worst, I have docker setup where this is appering, works on my home computer, but not on the server .. in the container with no difference between them... makes no sense to me – Erik Landvall Aug 24 at 17:47

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.