skip to Main Content

Problem

The app started by running streamlit run main.py will display http://IP_ADDRESS:8501 is displayed correctly, but http://DOMAIN_NAME stops with "Please wait… " and stops.

enter image description here

Environment

  • Domain name already resolved with Route53
  • Deploy Streamlit App on EC2 (Amazon Linux) and run Streamlit run main.py on Tmux
  • Use Nginx to convert access to port80 to port8501

Changed Nginx settings

/etc/nginx/nginx.conf

server {
        listen       80; #default
        listen       [::]:80; #default
        server_name MY_DOMAIN_NAME;
        location / {
          proxy_pass http://MY_IP_ADDRESS:8501;
        }
        root         /usr/share/nginx/html; #default

What I tried

I tried the following, but it did not solve the problem.

https://docs.streamlit.io/knowledge-base/deploy/remote-start#symptom-2-the-app-says-please-wait-forever

  • streamlit run my_app.py --server.enableCORS=false

  • streamlit run my_app.py --server.enableWebsocketCompression=false

5

Answers


  1. Try the following conf:

    server {
        listen 80 default_server;
        server_name MY_DOMAIN_NAME;
    
        location / {
            proxy_pass http://127.0.0.1:8501/;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 86400;
        }
    

    and then, use this command line:

    streamlit run my_app.py --server.port 8501 --server.baseUrlPath / --server.enableCORS false --server.enableXsrfProtection false
    
    Login or Signup to reply.
  2. If anyone is using Ambassador as their ingress to kubernetes you’ll need to allow websockets. This is explained at https://www.getambassador.io/docs/edge-stack/latest/howtos/websockets/

    But, you essentially need to add the following to your Mapping

    allow_upgrade:
    - websocket
    
    Login or Signup to reply.
  3. --server.headless=true
    

    I think the only problem is Streamlit trying to open a browser, so simply add this parameter in your run command:

    • streamlit run my_app.py --server.headless=true

    or try to change this in the config file which is you need to create:

    Refer to this explanation.

    Login or Signup to reply.
  4. Try to upgrade Streamlit code to version 1.11.1.

    Refer to this link: https://discuss.streamlit.io/t/security-notice-immediately-upgrade-your-streamlit-code-to-version-1-11-1/28399:

    On July 27th, 2022, we learned of a potential vulnerability in the
    Streamlit open source library that impacts apps that use custom
    components. The vulnerability does not impact apps hosted on Streamlit
    Cloud.

    We released a patch on the same night, July 27th, 2022 at 2:20PM PST,
    and ask that you immediately upgrade your Streamlit code to version
    1.11.1 or higher. You can read more in this vulnerability advisory

    Login or Signup to reply.
  5. In my case, the fix was downgrading streamlit from v1.14.0 to v1.11.0.

    What didn’t work:

    1. --server.headless=true
    2. --server.enableCORS=false
    3. --server.enableWebsocketCompression=false

    How was the app deployed? GCS using Cloud Run

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search