Deploying Streamlit on GCP (Cloud Run): problem when using new multipage app feature

Hello guys!

I am attempting to deploy streamlit app on my Google Cloud project as a cloud run.

I have been using streamlit on gcloud for a while (only single-page apps).

I’ll describe the problem here:

  1. Dockerize streamlit multipage app.
  2. Serve dockerized streamlit on Gcloud run via the following command: `gcloud beta run deploy myapp --project project_id --image --platform managed --allow-unauthenticated --memory “4G” --timeout “3600” --cpu 4 --concurrency 10
  3. Access the home-page → it works:
  4. Select another page inside the app (also works!):
  5. THE PROBLEM: if I try to access a secondary page directly from URL (simple F5 from last pic), I get the following state:

I tried investigating the cause of this problem for a while now, but up to this point I didn’t find any solution!

When deploying my docker image locally this does not happen (F5 works fine).

Also, the st.download_button() is not working on my Cloud Run instance…

Anyone ?


+1 also having this issue on GCP with Cloud Run when trying to access any page besides the main the page via the url, i.e. works but does not.

1 Like

Try to use your browser inspection tool to understand what is the difference between the requests from Cloud Run server before and after refreshing on the page. Increase ‘–logger.level’ could help to debug the requests in the server side. My actual guess would be that there is a server configuration problem, because you can connect to the server without using /subpage, so there is a huge chance that is not GCP network configuration problem. For the same reason I think that is not docker container configuration problem (but I could be wrong).

I had the same problem to access my app, but my problem affected all the pages when using Github Codespaces to develop the code. I would recommend to try the solution of this topic, maybe would resolve.

The starting script

streamlit run <file>.py --server.enableCORS false --server.enableXsrfProtection false

+1 Same issue here. We also use a GCP load balancer. I tried the fixes proposed by streamlit, but unfortunately it didn’t work.

In the link above it is proposed to run the app with:

streamlit run --server.enableCORS=false --server.enableWebsocketCompression=false

The ability to refresh your pages is essential when your app is deployed with Cloud Run. Because, when your deployment scales back to zero instances due to inactivity, Streamlit gives a connection error as it needs a persistent connection. When you refresh your page, Cloud Run scales up and your Streamlit app should work again.

Hello guys!

I prepared the reply but I did not reply!

I found the “solution” on these topics: /healthz route of an app deployed on Google App Engine returns 404 - Stack Overflow

The “solution” (more like a temporary work-around), adapted for me, was to add this:
find /usr/local/lib/python3.9/site-packages/streamlit -type f \( -iname \*.py -o -iname \*.js \) -print0 | xargs -0 sed -i 's/healthz/health-check/g' && streamlit run --server.address --server.port ${PORT:-8501}

1 Like

Does this fix the “please wait…” error when refreshing a secondary page?


You can check the Inspect tool, there are a bunch of /healthz requests, but it is reserved by google.

So streamlit and GCP are trying to use /healthz and the mix-up somehow breaks the app…

1 Like

+1 encountering the same issue. tried replicating the demo of one youtuber to isolate if its my/our code or gcp. yet both apps (mine and his) are working locally…