Apache: No space left on device

You may receive an error such as the one above while restarting Apache. Most people tend to believe that they are running out of disk space, but that is not the case. The apache error logs will show errors similar to the ones below and you may be surprised to know that this is not necessarily a space issue as shown by the error. You may also notice that apache is not bound to any port. The Apache error logs may show:

semget: No space left on device
OR
Apache: No space left on device: Couldn’t create accept lock

This is about Semaphores. What is a semaphore? Semaphores are used for communicating between active processes.
In this case it is used for communicating between apache parent and child processes. Apache writes down information before the activate processes communicates. If apache is unable to write such things down, the processes are unable to communicate resulting in the above error. Here is the way you can track down the current semaphores and kill those processes.

ipcs -s

This will list all the current semaphore IDs, their owner (httpd or nobody) and their permissions. You can kill those processes using

ipcrm -s PID

If they are plenty in numbers use the below command:

for i in `ipcs -s | awk ‘/httpd/ {print $2}’`; do (ipcrm -s $i); done
for i in `ipcs -s | awk ‘/nobody/ {print $2}’`; do (ipcrm -s $i); done

Apache can now be started without any problems.

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.