Flask file upload limit Flask file upload limit flask flask

Flask file upload limit


Use a production WSGI server will solve this problem (e.g. Gunicorn, Waitress). Below is a simple timeline of this issue.

2015

In this snippet (gone) that posted by Armin Ronacher, he said:

You might notice that if you start not accessing .form or .files on incoming POST requests, some browsers will honor this with a connection reset message. This can happen if you start rejecting uploads that are larger than a given size.

Some WSGI servers solve that problem for you, others do not. For instance the builtin Flask webserver is pretty dumb and will not attempt to fix this problem.

2018

I added a tip in the Flask's file uploading docs (flask #2662):

Connection Reset Issue

When using the local development server, you may get a connection reset error instead of a 413 response. You will get the correct status response when running the app with a production WSGI server.

2021

I think/hope it will be fixed in Werkzeug in the near future (werkzeug #1513).