404 sometimes when clicking on download button Streamlit on Cloud Run

Dear friends,

I deployed my streamlit app via Google Cloud Run and have been experiencing 404 errors for one of the apps (there’s 16 mini apps in total) [SEO/Social > Bulk SEO Stats Checker]

Download function code:

def excel_download(df):
    towrite = io.BytesIO()
    # write to BytesIO buffer
    df.to_excel(towrite, encoding='utf-8', index=False, header=True) 
    # reset pointer
    towrite.seek(0) 
    return st.download_button("Download", towrite, file_name="Guidesify_App.xlsx", mime='data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')

The app has a download button to export the generated dataframe as a .xlsx file and this works perfectly fine locally but breaks sometimes on GCP. When the 404 error happens, users have to refresh/resubmit their query to generate a new download.

Initially, I thought it could be something to do with Deploying Streamlit on GCP (Cloud Run): problem when using new multipage app feature but applying the suggested fix did not solve this issue.

Was thinking if this has to do with the maximum requests per container field (screenshot attached below).
image

Appreciate any help thanks! :slight_smile:

Stumbled upon this. If you haven’t figured it out yet, I think the need for sticky routing is why:

I’m looking for an easy fix too but I don’t think there will be one.

Thanks, this post definitely explains why. I have not found the solution yet and ended up building a Svelte + Supabase version of it lol!

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