File upload fails with Error: Request failed with status code 403

Hi all,

I’m a DevOps engineer working with AWS cloud, and I’m following a project where I need to deploy a Streamlit application on Internet through AWS.

We got the error: “Error: Request failed with status code 403” after uploading a file through the file_uploader. It turns out that the error was the Application Load Balancer in front of the server hosting Streamlit. The Application Load Balancer was protected by Web Application Firewall rules, and one of these blocks all the packets that has a body larger than 8 KB (typical of file upload). The name of the AWS WAF rule was SizeRestrictions_BODY.

By disabling this rule, everything worked fine. Don’t know if this can be helpful for whoever has issues in exposing Streamlit from cloud environments.


Hi, were you able to solve this issue? I have exactly the same problem, also when deploying to Azure, works fine locally.


1 Like

Do you have anything between your app and the users on Azure?

Try turning off XSRF protection by adding:

enableXsrfProtection = false

to streamlit/config.toml, or --server.enableXsrfProtection=false to the run command. Note that this is not really a recommended long-term / production use; I figure I am safe enough just by having an AD authentication requirement and a small & trusted user pool.

Here are some other topics on the problem, including my own. I have not been able to get a satisfying solution yet:

I have a low-confidence suspicion that this is caused by the _xsrf token not getting through. I opened up an issue here but I might be way off my base as webdev stuff is not my forte.

Ugh just hit the same exact issue. Running locally in an conda environment

Hi, I’m getting this error.
I’m getting this error when using the streamlit via IFRAME. It’s all local.

What can I do?

1 Like

Hi, I am getting same error with my Azure web app. when I tried locally I didn’t got any error. but in Cloud getting this error.

In documentation as per below link Symptom #3.

(App is not loading when running remotely - Streamlit Docs).

I have tried turning of XSRF protection it worked for me. so as per the suggestion we should enable same cookie secrets for replica.

Here my question is I am running app on single azure instances but why it is not working with XSRF enabled.

Please let me know if anyone have any other solution.

1 Like

This works for me too in Azure web app, after adding authentication. as @ennui and @Rachamadugu_Abhinay had suggested.

1 Like

If you’re running in auto rerun mode, try to restart your streamlit app server.

1 Like

The same is here. First time in Streamlit and want to deploy a new project but get an error-Request failed with status code 403. Did anyone have a solution? I’ve tried to clear cache, it doesn’t help

1 Like

I’m getting the same error. Did you find a solution?

1 Like

You need to add this on the config.tml file:

enableXsrfProtection = false
enableCORS = false

That worked for me. More on config files: Configuration - Streamlit Docs

1 Like

Hello @Charly_Wargnier!
I have an Error with the file upload like this:

could you help me with this error massage?

1 Like

Buenas noches tengo el error 403, solución por favor urgente gracias, es para mi proyecto

Hey buddy did you solve your issue, I am also facing the same issue

Hi, can you please assist, I get the same error.


Just started with streamlit and python , I am running the streamlit app locally but whenever I try to upload a pdf it gives me a error saying it is forbidden with the error code 403 , Can anyone help me out with this problem

1 Like

Hello @Charly_Wargnier Streamlit Team, I am also facing the same issue , is there any bug in it, as per the previous comment you have mentioned regarding the url change and other thing. How do we get it resolved. Thanks in advance for help.


I have the same issue. Streamlit version 1.30.0 - only just upgraded today and it stopped working. I’m running this on localhost:8501

1 Like

I have encountered the same issue AxiosError: Request failed with status code 403 for CSV uploads. This happened once I upgraded from 1.29 to 1.30. I have downgraded for now.

1 Like

hey, did you solve this issue??