File upload error - AxiosError: Request failed with status code 500

I just had an error when upload a xlsx file. it shows error " AxiosError: Request failed with status code 500". My app is working well on 7/27 but there must be some overnight changes that trigger this one.

The strange thing is there is NO error if I run it on Firefox. Chrome and Edge both have this error…any help? And I tried to downgrade to version 1.23 and 1.24, both are not working.

I get same error. However the situation is different.

When I try to upload from app hosted at streamlit.io , everyting works fine.

Soon as when I upload from a wordpress page hosted on a different domain, which embed this app, things does NOT work.

And I get exact same error.

Anyone knows what could be wrong ?

Could this because

Hi @Dawei @John_K, :wave:

Thanks for reporting this behavior.

I’m not too sure, so I’ve sent it to the devs. Please bear in mind that you may not have a response before Monday.

Thanks for your patience!

Charly

Hi @Charly_Wargnier,

Having the same issue. I have 2 separate frontends (one is react hosted on AWS amplify and the other is nextjs hosted on vercel). Each embeds a streamlit app, which itself requires a file upload. Up till a few days ago, these were working normally. But for some reason, now I also get the same error - “AxiosError: Request failed with status code 500”. The timeline seems to match what @John_K reported above. Is this a streamlit cloud side issue or something I have to change in my app?

Thank you!

Most probably code issue/changes from Streamlit Cloud side. We’re still investigating.

Thanks for your patience,

Best,
Charly

1 Like

Any resolution with this? I’m getting the same error

Same story here, upload form is working on Firefox but not on Chrome/Edge (on Windows 10, but other users experienced the same behaviour on mobile browsers).

Hi @shivam-singhal / @nzylakffa,

I’ve liaised with the devs and the issue is still under investigation.

We’ll come back to you as soon as we have more information on a resolution.

Thanks for your patience,

Best,
Charly

Hey @shivam-singhal ,

I’ve tried this feature out and it works fine on React or Next-based interfaces. Feel free to check out my project here with that same feature enabled: https://pneumoscan.vercel.app/

The code chunk I used to embed it had an api query of embedded set to true: > <iframe

      className="mt-4 w-full h-screen"
      src={"https://devtechjr-pneumoscan-model-app-drswsb.streamlit.app/?embedded=true"}
    ></iframe>

Please try this out and let me know if it works!

Hope this helped!

any update on this problem? I use iframe and put it on 2 websites, all resulted errors, but works normally on streamlit cloud.

1 Like

@faizhalas @Anirudh_Vangara @piclem

I’ve liaised with our devs and requested an update.

Thank you for bearing with us! :slight_smile:

Charly

1 Like

Thank you sir!

1 Like

@000 @faizhalas @Anirudh_Vangara @piclem

Some feedback from @kajarenc, one of our Software engineers:

After investigation, my best understanding is that file_uploader fails for apps deployed in Streamlit Cloud because of a misconfigrued _xsrf token, the interesting thing is that xsrf protection is disabled for all Cloud apps, but for some reason old apps still running with --enableXsrfProtection=true and just rebooting it doesn’t change it. But creating a container from scrach (attempt to deploy that app with a different domain?) solves that problem.

So the solution for Streamlit Cloud apps will be either try to redeploy the app (not just reboot), or explicitly specify:

[server] enableXsrfProtection = false

in app config.toml

If you’re still facing the issue, could you please try one of these solutions?

Best,
Charly

2 Likes

problem solved sir!

This method did not help me, I have the application running locally on the server and inserted by container to the site, maybe there are some other ways to solve in my case?

Thank you in advance for the answer!

1 Like

Hi @brryz0r

Running the app locally and embedding it via a container might introduce additional complexities. Here are a few things you could try:

  • Inspect the server logs for detailed error messages.
  • Update Streamlit to its latest version.
  • Reboot the app.
  • Ensure the CORS configuration on your local server is correctly set up.
  • Verify there are no network restrictions or firewalls blocking requests.
  • Test the app across different browsers to spot browser-specific issues.

Let us know if any of the above helps you.

Best,
Charly

I started learning Streamlit recently. While trying to implement a very simple file uploader application locally, I am getting the same error. Sharing the code and the error too.
Streamlit version 1.30.0, OS Windows 8.1

File upload tutorial

#core packages
import streamlit as st

File processing packages

from PIL import Image

#load images
#@st.cache #used to make the load process faster
def load_image(image_file):
img=Image.open(image_file)
return img

def main():
st.title(“File upload tutorial”)
menu=[“Home”,“Dataset”,“DocumentFiles”,“About”]
choice=st.sidebar.selectbox(“Menu”,menu)
if choice==“Home”:
st.subheader(“Home”)
image_file=st.file_uploader(“Upload Images”,
type=[“png”,“jpg”,“jpeg”])
if image_file is not None:
st.write(type(image_file))
#methods/attributes
#st.write(dir(image_file))
file_details={“filename”:image_file.name, “filetype”:image_file.type,“filesize”:image_file.size}
st.write(file_details)
st.image(load_image(image_file),width=250,height=250)

elif choice == "Dataset":
    st.subheader("Dataset")
elif choice =="DocumentFiles":
    st.subheader("DocumentFiles")
else:
    st.subheader("About")

if name==‘main’:
main()

Error:
AxiosError: Request failed with status code 403

Hello Everyone,

Its easy fix…If you are running it locally

streamlit run app.py --server.enableXsrfProtection false

1 Like

streamlit run app.py --server.enableXsrfProtection false

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.