In a Debian lenny server running postgresql, I noticed that a lack of semaphore arrays is preventing Apache from starting up.

Looking at the limits, I see 128 arrays used out of 128 arrays maximum, for semaphores. I know this is the problem because it happens on a semget call.

How do I increase the number of arrays?

PS: I need Apache running to make use of phppgadmin.

  • I'm kind of surprised you managed to hit that limit -- I run apache and pgsql on multiple servers at my workplace without encountering that limit. One thing that might be of help is that phppgadmin doesn't necessarily need to run on the same server as postgresql... Commented May 6, 2011 at 16:56
  • @Shadur I suspect there are lost semaphores from early crashes. I can't do anything about that at the moment, though, so I'm considering my other options. Commented May 6, 2011 at 17:04
  • In that case I recommend you find some way to clear the lost semaphores and find out what keeps crashing, or raising the limit will just get you in trouble again when the new limit is reached... Commented May 6, 2011 at 17:53
  • @Shadur It is not crashing anymore, but to clear the semaphores I need to stop the database, and it will take a while before I get a window to do that. Commented May 6, 2011 at 18:47
  • You can RECOMPILE, the Linux OS, and increase the hard limit. I bumped it up to thousands, because that's what I was using for one client (they were porting unix code to linux).. norman.
    – user80994
    Commented Aug 15, 2014 at 21:36

1 Answer 1


If you read the manpage for semget, in the Notes section you'll notice:

System wide maximum number of semaphore sets: policy dependent (on Linux, this limit can be read and modified via the fourth field of /proc/sys/kernel/sem).

On my system, cat /proc/sys/kernel/sem reports:

250 32000   32  128

So do that on your system, and then echo it back after increasing the last number:

printf '250\t32000\t32\t200' >/proc/sys/kernel/sem

(There are tab characters between the numbers, so I'm using printf to generate them.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .