I'm uploading a .wav file of size around 5745kb, the limitation in the nginx config is set as

client_max_body_size 10m;

The upload fails with error as "Request entity too large" and content-length from request headers show that size is more than 10 Mb

Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 10780638
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryM7ttYsUBvcDf577T

Since the expectation is file should have been allowed, how does internally file size gets changed?

  • Did you allow big enough size files to be uploaded by PHP in php.ini? – Bert Mar 6 at 10:39
  • I'm using a rails application, on the rails end i have a check for 10mb file sizes. My concern is file while uploading changes it's size while sitting as temporary file in browser? – Bijendra Mar 6 at 10:43
  • I don't really get it. It is natural that files size is changing while uploading, since they not just "appear" there, they have to be transferred bit-by-bit. Or what you mean they are increasing on the local machine during upload? In that case, that could be the issue. Because when a file upload starts, 1st it sends the server the details about the file. Like size. And if the actual size differs from what the server was told to at the beginning, then your uploads will fail every time. You must lock the file during upload then. – Bert Mar 6 at 10:46


large_client_header_buffers 4 16k;

right after your client_max_body_size option. Should work like a charm.

Also, always set about 10-20% more for uploadable file size that you are currently wanting to upload. Threshold, you know. ;)

  • large_client_header_buffers I had tried this and it didn't help since max limit was 10mb, file was still being rejected. Currently i need to set 40% in conf file if the file size needs to be allowed – Bijendra Mar 6 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.