Recently we are experiencing this problem.
When trying to upload an image file using st.file_upload, we get the 403 AxiosError.
See the attached image.
What causes this?
How can we resolve this?
Sudipta
Welcome to the Streamlit community, Sudipta! Thanks for sharing your question and the screenshot—super helpful! ![]()
The “AxiosError: Request failed with status code 403” when using st.file_uploader is a common issue, especially when deploying Streamlit apps outside of localhost (e.g., on cloud platforms, behind proxies, or with authentication enabled). The root cause is usually related to Cross-Site Request Forgery (XSRF) protection or CORS misconfiguration, which blocks the upload request for security reasons. Disabling XSRF protection often resolves the issue, but be aware this reduces security and should only be used in trusted environments. To disable XSRF protection, add the following to your .streamlit/config.toml file:
[server]
enableXsrfProtection = false
Or, run your app with the flag:
streamlit run your_app.py --server.enableXsrfProtection=false
For more details and community discussions, see this forum thread and the Streamlit documentation.
If you’re deploying behind a load balancer or proxy, ensure session stickiness is enabled and that cookies are handled correctly, as described in the Streamlit architecture docs. Also, check that your deployment platform isn’t stripping cookies or headers required for file uploads.
Sources: