I have a small Django (1.2.x) project deployed on Apache (2.x) via mod_wsgi (3.x). In the admin, if I upload a file < 1MB, I can get it through; however, for a file, say, 1.2MB in size, I get a 400 response from the server with "Error 400" in the body only. I am wondering why this is happening. As far as I can see, there is no LimitRequestBody set in Apache configuration. I have tried uploading with several browsers including: Firefox, Chrome, and Safari.

In the log file for Apache, there is apparently no entry for requests that gave the 400 error response. This is strange.

I should point out that the scenario where this is happening is thus: The project in question is deployed on two identical Apache servers (completely identical setup) that are behind a load balancer. On my development setup, of course, the problem does not surface.

Any help with this will be very much appreciated.

UPDATE: I have found out that the following error message is logged for the load balancer: Bad request headers : Content-length exceeds post body limit. The other interesting bit is that, if the file > 1 MB is uploaded over HTTPS, it goes through fine. However, when it is uploaded over HTTP, it gives out the 400 error.

UPDATE #2: I decided to write a simple file upload program using simply Python and web.py. I got it to be deployed on the production server under the same virtual host configurations, under mod_wsgi. The file uploads worked when the application was served over SSL. But they gave the Error 400 when they were served over non-SSL. So, I am even more stumped than before.

  • If at all possible, you should try circumventing the firewall and uploading it to a single server directly. It seems likely that the load balancer is preventing file uploads of over 1MB.
    – Andrew M.
    Mar 19, 2011 at 20:47
  • You are using an old mod_wsgi, upgrade to mod_wsgi 3.3 to start with. Also, did you by chance decide to throw out the complete default Apache configuration and use instead your own minimal configuration. Mar 20, 2011 at 4:02
  • Hi guys. Thanks very much for your comments. Since the problem is happening on the production environment and I don't have direct access to it, I can only request to have different things tried out. I have updated the question with some more information.
    – ayaz
    Mar 22, 2011 at 18:36

1 Answer 1


I am going to answer this myself as the problem has been resolved. Thanks very much to both Redmumba and Graham Dumpleton for their comments.

The problem was certainly not with Django (as we had already established). However, it turned out not to be with Apache. The problem was with the firewall on the system that the system admins had forgotten about completely (sigh). Apparently, the firewall had a file size limit of 1MB imposed.

You must log in to answer this question.

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