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…
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.