I have my local development server returning status 413 for oversized file uploads and the client is receiving these immediately - as I require.

My remote server is the same version of Nginx and more-or-less the same configuration, but the 413 never reaches the browser.

An error indicating the data is oversized appears in the error log straight away and nothing appears in the access log. The browser continues to send the data and after 30 seconds the 413 status appears in the access log (and again in the error log) and the browser times out with an internal 'connection reset' error.

What configurations on the remote server could cause this delay?

  • Starting to wonder if it's the latency that's the difference. Local network being fast enough that the file can upload before the timeout period and get the 413 response. i.e. The browser must send the whole file before receiving a response, and over the web that's too long. -- thinking out loud. – Tim Feb 17 '12 at 9:09

The problem is that most HTTP clients don't read the response until they've sent the entire request body. If you're dealing with webbrowsers you're probably out of luck here. The only server side configuration you can do is set keepalive_requests to 0 (which disables persistent connections), which might make nginx close the connection after sending the 413 which should cause the client to stop sending the data. The client is likely to report a network error instead of 413 however.

  • Yeah, this will likely result in the client reporting "connection reset by peer" rather than actually reading and parsing the response body. – Joe Shaw Nov 16 '12 at 21:01

I guess browser must still finish the upload and only then recieve 413 error. The best way to check file size is to check it in JS before hitting the upload button.

  • That certainly is the best way, and I am doing for /modern/ browsers. I've tried to use the Microsoft ActiveX thing to do the same in IE, but it produced nasty security warnings, so I ditched my attempts at that. – Tim Aug 10 '12 at 12:20

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.