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.
Symptom #1: The app never loads
When you enter the app's URL in a browser and all you see is a blank page, a "Page not found" error, a "Conection 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 my_app.py --server.port=80
AWS EC2 server: First, click on your instance in the AWS Console. Then scroll down and click on Security Groups → Inbound → Edit. Next, add a Custom TCP rule that allows the Port Range
8501
with Source0.0.0.0/0
.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]
Symptom #2: The app says "Please wait..." forever
If when you try to load your app in a browser you see a blue box in the center of the page with the text "Please wait...", the underlying cause is likely one of the following:
- Misconfigured CORS protection.
- Server is stripping headers from the Websocket connection, thereby breaking compression.
To diagnose the issue, try temporarily disabling CORS protection by running
Streamlit with the --server.enableCORS
flag set to false
:
streamlit run my_app.py --server.enableCORS=false
If this fixes your issue, you should re-enable CORS protection and then set
browser.serverPort
and browser.serverAddress
to the URL and port 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 my_app.py --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.
Symptom #3: Unable to upload files when running in multiple replicas
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 my_app.py --server.enableXsrfProtection=false
If this fixes your issue, you should re-enable XSRF protection and then
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.