My app configuration sets the max size of a file upload to 20 MB ( MAX_CONTENT_LENGTH = 20 * 1024 * 1024). The client includes the Content-Type’: ‘multipart/form-data’.
I’m at a loss to understand what is preventing my ability to have clients upload files greater than 1 MB (I can upload 0.8 MB).
Thank you for any confirmation of what to expect so that I can isolate the issue.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there,
What I could suggest is as a means of isolating the issue, if possible, try uploading directly to the Flask application (bypassing the Load Balancer). If it works, then the issue is likely with the Load Balancer or the network in between. If it doesn’t, the issue is within the Flask app or its immediate hosting environment.
The “413 Payload Too Large” error can be generated by several components in your infrastructure.
If this does not work even without the load balancer, what I could suggest is:
Double-check your Flask app’s configuration to make sure
MAX_CONTENT_LENGTH
is correctly set to20 * 1024 * 1024
.Web Server Configuration:
If you’re using a web server like Nginx or Apache to serve your Flask app, they have their own client body size limits.
For Nginx: Check your Nginx configuration for the
client_max_body_size
directive. By default, it’s set to 1MB. To set it to 20MB, you’d add:to your server or location block in the Nginx configuration.
For Apache: If you’re using mod_proxy, you might need to tweak
LimitRequestBody
. The default is unlimited, but if it’s set, it could be causing the issue.Error Logs:
Middleware or Proxy:
Let me know how it goes!
Best,
Bobby