Suppressing "connection error" message

I deployed my Streamlit app on Google Cloud Run. After a few minutes when the Run instance quits, I get a “Connection error”. Is there a way for the Client App to trap this error gracefully to either dismiss it or provide a better message? Or is there a good workaround for idling apps to not show this error.

Hey @asw888,

one workaround would be to remove the connection message via a CSS hack. To do that you would need to add the following code to your app:

import streamlit as st

hide = """
<style>
div[data-testid="stConnectionStatus"] {
    display: none !important;
</style>
"""

st.markdown(hide, unsafe_allow_html=True)
1 Like

Thanks @lukasmasuch. Good technique. I was actually looking for a way to suppress the big error dialog that pops up when the server no longer exists. Using your technique, I was able to identify the div for the dialog box via the class attribute (although a very long string) and apply the “display: none” style. Seems to be working! Thanks for the tip.

1 Like

Can you provide some more insight how that worked?

Thanks,
Franz

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