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:
Dockerize streamlit multipage app.
Serve dockerized streamlit on Gcloud run via the following command: `gcloud beta run deploy myapp --project project_id --image gcr.io/myapp:dev --platform managed --allow-unauthenticated --memory “4G” --timeout “3600” --cpu 4 --concurrency 10
+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. my.page works but my.page/subpage does not.
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 my_app.py --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.
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 main.py --server.address 0.0.0.0 --server.port ${PORT:-8501}
+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…