Philipp's Computing Blog

Success is about speed and efficiency

[fix] mod_fcgid: HTTP request length xyz (so far) exceeds MaxRequestLen (131072)

I found the following problem in the apache2 error log:

[Tue Apr 26 21:47:31 2011] [warn] [client 66.187.211.41] mod_fcgid: HTTP request length 132101 (so far) exceeds MaxRequestLen (131072), referer: http://example.com/upload.php?post_id=38&type=image&

It can occur when uploading a file that is too large on an Apache web server with mod_fcgid enabled. The solution is to set MaxRequestLen to a larger value.

To do so edit the apache2 fcgid module configuration file fcgid.conf using vi /etc/apache2/mods-available/fcgid.conf and change the content from

<IfModule mod_fcgid.c>
  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 20
</IfModule>

to

<IfModule mod_fcgid.c>
  # see: http://goo.gl/OUHdM
  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 20
  # to get around upload errors when uploading images increase the MaxRequestLen size to 15MB
  MaxRequestLen 15728640
</IfModule>

If you also get errors such as

[Thu May 31 14:33:40 2012] [warn] [client 84.38.19.68] mod_fcgid: read data timeout in 40 seconds
[Thu May 31 14:33:40 2012] [error] [client 84.38.19.68] Premature end of script headers: index.php

you should extend the config file to:

<IfModule mod_fcgid.c>
  # see: http://goo.gl/OUHdM
  AddHandler    fcgid-script .fcgi

  # fix for:   mod_fcgid: read data timeout in 40 seconds
  IdleTimeout 3600
  DefaultMinClassProcessCount 100
  FcgidConnectTimeout 120
  IPCCommTimeout 400

  # to get around upload errors when uploading images increase the MaxRequestLen size to 15MB
  MaxRequestLen 15728640
</IfModule>

Resources