App is not loading when running remotely

Below are a few common errors that occur when users spin up their own solution to host a Streamlit app remotely.

To learn about a deceptively simple way to host Streamlit apps that avoids all the issues below, check out Streamlit Community Cloud.

When you enter the app's URL in a browser and all you see is a blank page, a "Page not found" error, a "Connection refused" error, or anything like that, first check that Streamlit is actually running on the remote server. On a Linux server you can SSH into it and then run:

ps -Al | grep streamlit

If you see Streamlit running, the most likely culprit is the Streamlit port not being exposed. The fix depends on your exact setup. Below are three example fixes:

  • Try port 80: Some hosts expose port 80 by default. To set Streamlit to use that port, start Streamlit with the --server.port option:

    streamlit run --server.port=80
  • AWS EC2 server: First, click on your instance in the AWS Console. Then scroll down and click on Security GroupsInboundEdit. Next, add a Custom TCP rule that allows the Port Range 8501 with Source

  • Other types of server: Check the firewall settings.

If that still doesn't solve the problem, try running a simple HTTP server instead of Streamlit, and seeing if that works correctly. If it does, then you know the problem lies somewhere in your Streamlit app or configuration (in which case you should ask for help in our forums!) If not, then it's definitely unrelated to Streamlit.

How to start a simple HTTP server:

python -m http.server [port]

This symptom appears differently starting from version 1.29.0. For earlier versions of Streamlit, a loading app shows a blue box in the center of the page with a "Please wait..." message. Starting from version 1.29.0, a loading app shows skeleton elements. If this loading screen does not go away, the underlying cause is likely one of the following:

  • Using port 3000 which is reserved for internal development.
  • Misconfigured CORS protection.
  • Server is stripping headers from the Websocket connection, thereby breaking compression.

To diagnose the issue, first make sure you are not using port 3000. If in doubt, try port 80 as described above.

Next, try temporarily disabling CORS protection by running Streamlit with the --server.enableCORS flag set to false:

streamlit run --server.enableCORS=false

If this fixes your issue, you should re-enable CORS protection and then set browser.serverAddress to the URL of your Streamlit app.

If the issue persists, try disabling websocket compression by running Streamlit with the --server.enableWebsocketCompression flag set to false

streamlit run --server.enableWebsocketCompression=false

If this fixes your issue, your server setup is likely stripping the Sec-WebSocket-Extensions HTTP header that is used to negotiate Websocket compression.

Compression is not required for Streamlit to work, but it's strongly recommended as it improves performance. If you'd like to turn it back on, you'll need to find which part of your infrastructure is stripping the Sec-WebSocket-Extensions HTTP header and change that behavior.

If the file uploader widget returns an error with status code 403, this is probably due to a misconfiguration in your app's XSRF protection logic.

To diagnose the issue, try temporarily disabling XSRF protection by running Streamlit with the --server.enableXsrfProtection flag set to false:

streamlit run --server.enableXsrfProtection=false

If this fixes your issue, you should re-enable XSRF protection and try one or both of the following:

  • Set browser.serverAddress and browser.serverPort to the URL and port of your Streamlit app.
  • Configure your app to use the same secret across every replica by setting the server.cookieSecret config option to the same hard-to-guess string everywhere.

Still have questions?

Our forums are full of helpful information and Streamlit experts.