Requests has stopped working

Please take a moment to search the forum and documentation before posting a new topic.
If you’re creating a debugging post, please include the following info:

  1. Are you running your app locally or is it deployed?
  2. If your app is deployed:
    a. Is it deployed on Community Cloud or another hosting platform?
    b. Share the link to the public deployed app.
  3. Share the link to your app’s public GitHub repository (including a requirements file).
  4. Share the full text of the error message (not a screenshot).
  5. Share the Streamlit and Python versions.

Hi My streamlit app has worked fine periodically fails with the following error. I am running in the cloud but interestingly it works fine locally and has worked OK for long periods in the cloud

Any help would be appreciated

Hey there, thanks for sharing your question and all the details! :blush: When your Streamlit app works locally but periodically fails on Streamlit Community Cloud with a requests.exceptions.ConnectTimeout error, it usually means the app is unable to reach an external service (like an API or database) within the allowed time. This can be due to network latency, stricter outbound connection limits, or temporary network issues on the cloud platform. The error is not specific to Streamlit itself, but rather to the requests library timing out while waiting for a response from the target URL.

To address this, you can try increasing the timeout value in your requests call, add retry logic, and ensure the external service is accessible from Streamlit Cloud (sometimes you may need to allowlist Streamlit Cloud’s IPs on the external service). Also, check that your app isn’t hitting resource limits, as this can cause slowdowns and timeouts—see the Streamlit resource limits guide for optimization tips. If the issue persists, review your app’s Cloud logs for more context and consider implementing error handling to gracefully manage timeouts.

Sources: