500 internal server error while uploading files bigger then 100kb - mod_fcgid problem

Submitted by ivica on Fri, 08.07.2011

For no special reason Drupal sites on our server (CentOS 5 with cPanel/WHM) started to make problems with file upload. Because Drupal 6/7 has use Ajax for file uploading the only thing that happens is that browser just hangs until timing out. Quick playing with different file sizes revealed that files that are less then 100kb are OK, but bigger files are creating problem. Of course php post_max_size and upload_max_filesize are set to 20mb so that was not causing problems. Strange...

Actually the biggest problem here was finding out what the hell is happening. I quickly created small html/php script with file upload form, and when testing with files bigger then 100kb I immediately got 500 internal server error - OK, that is something but still not telling much. Most annoying thing was fact that php error_log and apache logs that I was getting from Cpanel and WHM were error empty.

Yes in CentOS (managed with cPanel) you have logs all over the place. Finally founded master apache log that I needed and there was explanation

[Fri Jul 08 12:36:14 2011] [warn] [client] mod_fcgid: HTTP request length 132356 (so far) exceeds MaxRequestLen (131072), referer: http://www.montenasoft.com/.../upload.html

So MaxRequestLen from mod_fcgid (and we are running fast cgi for PHP) is limiting request length to only 130kb - If the size of the request body exceeds this amount, the request will fail with 500 Server Error. Fix is easy you just need to add in your httpd.conf next lines

# Work around annoying fcgid limitations
<IfModule mod_fcgid.c>
  # 20MB should be enough
  MaxRequestLen 20000000

But again when you have WHM for server management things are not that easy ;) You can not just add those lines to /etc/httpd/conf/httpd.conf because next time when you update apache or php on your server your custom httpd.conf tweaks will be lost.

Here is a correct way to do, login to WHM and go to "Apache Configuration", and then select "Include Editor"

WHM httpd configuration - selcting include editor

Then in "Pre VirtualHost Include" section select "All versions" add custom MaxRequestLen configuration, and hit update.

adding custom configuration in 'Pre VirtualHost Include' section

And don't forget to restart apache on the end.

don't forget to restart apache

And that was it, no more 500 internal server error. Why this setting started to make problem recently is still unknown, maybe cPanel auto updates changed something silently.


by Ted Thompson on Thu, 21.07.2011

This was a lifesaver! Thanks so much. I recently moved to a new VPS with WHM/cPanel CentOS, I never had this problem before on my previous server. Have spent several hours reading about people digging through system files and editing conf files, and all along the solution was in WHM.

Thanks for the heads up! Now I can get on with some work....


by Guest on Sat, 27.08.2011

Man, You are simply the best, thanks a lot!

by neelan on Wed, 21.09.2011

Can you help me to edit apace Configuration files. i am using godaddy server. and i could not find apace configuration in their control panel. please help me where it will placed to do these changes.
THnaks and waiting...

by ivica on Sat, 24.09.2011

Sorry but I never used Godaddy hosting...

by Arber on Fri, 30.12.2011

That's exactly what fixed my problem in my dedicated server, great article (Y)

Thanks a tonne man! You really saved my ass with this blogpost :)
Thank you

by dolst on Tue, 06.12.2011

Thanks a bunch for this posting! I was working on a customer's Plesk site, and this was exactly the problem (even with the same symptoms, such as the cryptic and annoying empty log files!).
I believe you saved me much work, and I am very grateful!
Just FYI, this customer just upgraded their Plesk about 2 weeks ago, so this was probably the culprit. Thanks again! Surf Wisely.

by Ruth Cheesley on Thu, 15.12.2011

We had this problem and I was rummaging around trying to find config files to edit, but this worked perfectly! One very happy bunny!


by Chris on Wed, 21.12.2011

Thanks for this post, saved me a lot of head scratching for sure! Sorted out my new VPS,

by Vlad on Wed, 01.02.2012

Awesome, thank you very much for those published details, save me a ton of research :)

by Benedikt Schmitz on Sun, 12.02.2012

Thank you so much! I didn't search that long to fix the problem. But just because I found this awesome solution fast as hell. Thank you!


I run a Joomla website and I get those 500 internal server errors. I checked on WHM and I have "FcgidMaxRequestLen 1073741824" (1Gb) but no use. Can you please indicate me another solution?

by Eranda on Sat, 14.07.2012

This one worked
I also had this one in my localhost.

by Zura on Sun, 28.10.2012

Thanks a lot! This fix finalized my headache that lasted one week!

by dezihngd on Tue, 18.12.2012

thx 4 this post mate. Very help full 4 me. ;)

by Joe on Sun, 24.02.2013

I just moved my site to a new server and had this same error when installing joomla extensions . Thanks so much for the easy fix!

by Anjali on Sat, 16.03.2013

That's exactly what i was looking for... Thank you so much for posting...

by Jon on Tue, 01.10.2013


A good solid week I have been looking for this answer! Thanks so much for posting! My setup is a little different but I found the file to amend in etc/apache2/apache2.conf

Thanks again!

by Andreas on Thu, 21.11.2013

After one day of struggeling I found this post! THANKS!