I’m encountering an issue with the st.file_uploader
function in Streamlit (version 1.38.0) with Python 3.9, when trying to upload image files approximately 2 MB in size. The error message is as follows:
AxiosError: Network Error (400)
Observations
- The issue occurs sporadically.
- It never happens with images smaller than 1.5 MB.
- For larger images, the error sometimes resolves after multiple upload attempts.
- This issue is specific to the production environment.
- The app runs without problems when tested locally.
- The production setup is an AWS Elastic Beanstalk environment using an ELB (Elastic Load Balancer) and a Dockerized EC2 instance running the application.
Troubleshooting Attempts:
We’ve tried several approaches suggested by other developers in similar scenarios:
- Updating the
maxUploadSize
parameter in the~/.streamlit/config.toml
file.- enableCORS=false, enableXsrfProtection=false, maxUploadSize = 1500
- Reference: Streamlit Community Discussion
- Increasing the ELB timeout setting.
- Reference: File Uploader Widget Issue
- Disabling Cross-Site Request Forgery (XSRF) protection via the
enableXsrfProtection
parameter in the~/.streamlit/config.toml
file.- Reference: Similar File Upload Error
- Deploying the app using bigger EC2 instances: In this test deployment we used an isolated EC2 instance to run the application and no ELB was included.
Given that the error seems to depend on the specific production architecture, does anyone have suggestions on how to resolve this issue? Any advice tailored to the AWS Elastic Beanstalk + Docker setup would be especially appreciated.