By edmundsecho
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!
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 to 20 * 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:
client_max_body_size 20M;
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.