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

The service “httpd” appears to be down.

OK just to give an update on this thread, so hopefully it helps someone else in the future.

Apologies in advance to any Level 18 Fire Breathing +5 SysAdmins; this is noob stuff :)

The cPanel team examined my server and determined that Apache had ran out of Semaphores.

Each time HTTPD crashed it didn’t release the semaphores and eventually my server ran out (I had 128). The cPanel team kindly cleared down the “locked” semaphores as follows:

Code:
[19:48:55 mail root@9019765 ~/cptechsjt]cPs# for i in `ipcs | grep admin | awk {'print $2'}`; do ipcrm -s $i; done
[19:49:06 mail root@9019765 ~/cptechsjt]cPs# /scripts/restartsrv_httpd ===

And the support analyst advised to read this article:

Apache: No space left on device: Couldn’t create accept lock – major.io

After reading it, I googled for corroboratory advice and found this article:

Semaphore limits and many Apache instances on Linux | End Point

So I decide to increase the number of semaphores from 128 to 256 as follows:

How many semaphores do I have?

Code:
# cat /proc/sys/kernel/sem
250 32000 32 128

Answer = 128

Add this line to /etc/sysctl.conf:

Code:
kernel.sem = 500 64000 64 256

To make the change take immediate effect, issue this command:

Code:
# sysctl -p

Alternatively perform a graceful reboot of your server, (If you can.)

So how many semaphores do I have now?

Code:
# cat /proc/sys/kernel/sem
500     64000   64      256

You can also check the number of “running” semaphores with this command:

Code:
# ipcs -s

I also noticed that one website (wordpress) was creating a disproportionate number of semaphores compared to the other websites (also wordpress) on my server, so it must be a rogue plugin. I will investigate further.

Thank you to great team at cPanel for helping me out, its genuinely appreciated.

Best Regards

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

This error completely stumped me a couple of weeks ago. Apparently someone was adjusting the Apache configuration, then they checked their syntax and attempted to restart Apache. It went down without a problem, but it refused to start properly, and didn’t bind to any ports.

Within the Apache error logs, this message appeared over and over:

[emerg] (28)No space left on device: Couldn't create accept lock

Apache is basically saying “I want to start, but I need to write some things down before I can start, and I have nowhere to write them!” If this happens to you, check these items in order:

1. Check your disk space

This comes first because it’s the easiest to check, and sometimes the quickest to fix. If you’re out of disk space, then you need to fix that problem. 🙂

2. Review filesystem quotas

If your filesystem uses quotas, you might be reaching a quota limit rather than a disk space limit. Use repquota / to review your quotas on the root partition. If you’re at the limit, raise your quota or clear up some disk space. Apache logs are usually the culprit in these situations.

3. Clear out your active semaphores

Semaphores? What the heck is a semaphore? Well, it’s actually an apparatus for conveying information by means of visual signals. But, when it comes to programming, semaphores are used for communicating between the active processes of a certain application. In the case of Apache, they’re used to communicate between the parent and child processes. If Apache can’t write these things down, then it can’t communicate properly with all of the processes it starts.

I’d assume if you’re reading this article, Apache has stopped running. Run this command as root:

# ipcs -s

If you see a list of semaphores, Apache has not cleaned up after itself, and some semaphores are stuck. Clear them out with this command:

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

Now, in almost all cases, Apache should start properly. If it doesn’t, you may just be completely out of available semaphores. You may want to increase your available semaphores, and you’ll need to tickle your kernel to do so. Add this to /etc/sysctl.conf:

kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

And then run sysctl -p to pick up the new changes.

Rolar para cima