503 server unavailable, errors in Apache log

Hi

Recently the server has the following entries appearing in the main apache error log :

[Sun Sep 04 12:42:58 2011] [error] (24)Too many open files: mod_fcgid: couldn't set child process attributes: /etc/httpd/run/mod_fcgid/16771.32 [Sun Sep 04 12:42:58 2011] [warn] (24)Too many open files: mod_fcgid: spawn process /home/redcarrot.co.uk/public_html/index.php error [Sun Sep 04 12:42:59 2011] [error] (24)Too many open files: mod_fcgid: couldn't set child process attributes: /etc/httpd/run/mod_fcgid/16771.33 [Sun Sep 04 12:42:59 2011] [warn] (24)Too many open files: mod_fcgid: spawn process /home/redcarrot.co.uk/public_html/index.php error

This is just a small sample, there are thousands of them! In addition, all websites are returning 503 Service Unavailable.

I have restarted Apache and the error is now fixed, but this has happened twice now over the last few days. Any idea what is causing this, and how I can prevent it?

Best wishes

Lewis

Status: 
Active

Comments

Howdy -- it looks like you're hitting an open files limit for the "apache" user. Do you have a lot of domains on your server?

One thing you might try is to edit /etc/security/limits.conf, and to add these lines:

apache       hard      nofile          16384
@apache    hard      nofile          16384

Then restart Apache:

/etc/init.d/httpd restart

That should setup Apache with higher limits.

While editing that limits.conf file, you'd also want to make sure there wasn't an existing "apache" limit setup in there.

Hi

Thanks for getting back. There are only around 10 websites on the server so far, it is relatively new.

I took a look at /etc/security/limits.conf - this is what it currently contains :

apache hard cpu -1

apache hard nproc -1

apache hard as -1

Should I replace these with the lines you suggested?

There is another thread on this forum ( https://www.virtualmin.com/node/8197 ) that suggests adding the following line in /etc/httpd/conf.d/fcgid.conf :

MaxRequestsPerProcess 500

-

What do you think I should do?

Best wishes

Lewis

You can add the lines I mentioned in addition to the other lines you have in the limits.conf... those are setting different parameters.

I'd start by making the limits.conf change first... if you still run into problems, you can always experiment with the "MaxRequestsPerProcess" option.