Ec2 streamlit stuck on loading screen while running streamlit hello

Hi, I exposed the 8501 port on ec2 as required but for some reason the screen is stuck on loading:


Any idea how to resolve this ?

1 Like

Try setting

[server]
enableCORS=false

in your ~/.streamlit/config.toml.

1 Like

Does this file already exist or should I create one ?

Great! that fixed the issue just created the file with the above value in it.

1 Like

Unfortunately, “enableCORS=false” doesn’t work.

After setting this option, I still get “Please wait
” screen when trying to connect to my EC2 (I’ve checked that the config is loaded properly via ‘streamlit config show’ and my 8501 port is open)

I’ve also tried binding it to 0.0.0.0 like when I deploy gunicorn (browser.serverAddress=“0.0.0.0”), as per How do I set the server to 0.0.0.0 for deployment using Docker

Not sure if it’s relevant, but when I try the /healthz route, I get “OK”.

Any other ideas on how to resolve this?
I’ve encountered the same issue on several other EC2 instances I tried. I was so excited to showcase your amazing app to our team tomorrow :cry:
(but regardless of this issue - this is an amazing tool, guys!! :+1:)

Update: It works when I run streamlit on localhost on EC2 (browser.serverAddress=“localhost”) and forward my port via SSH tunnel. But I still haven’t found a way how to make it accessible on instance’s public IP.

Update 2: I just got home and got a very strange behaviour.

  • At first, it was hanging at “please wait
” and I could see that ‘/stream’ call to websocket is timing out.
  • But after a while (c. 2mins) Hello app suddenly popped up (’/stream’ went through with status code 101). I could replicate this behaviour several times (a few mins of time outs and then pop up).
  • Now, when I refresh it loads immediately! I haven’t done any changes on EC2 (config is set to enableCORS=false, serverAddress=‘0.0.0.0’)

Update 3: It again stopped working this morning (despite no changes). Since then, I’ve tried multiple AWS accounts, regions, set ups and streamlit apps with no difference. Winning combo (when it works) is as per my Update 2, but it’s quite temperamental, which makes it hard to reproduce & debug
 I guess I’ll wait for a more stable release (EC2-wise).

For completeness: Issue is on path /stream that keeps hitting “WebSocket is closed before the connection is established.” and over time changes into “Error during WebSocket handshake: Unexpected response code: 503”

Update 4: Temporary solution seems to be to put your EC2 behind an ALB that forwards from port 80 to whatever your Streamlit port is (eg, 8501).

2 Likes

Hi all,
I had a similar issue when deploying on heroku. It would get stuck loading. I added the enableCORS=false to my setup.sh file and it worked for the simple data frames and charts examples from the ‘Get Started’ page.
I tried deploying the The Data Explorer app to heroku but I am getting the same errors I was getting on my Mac:

Funny thing is that the app works when I run it on locally on my machine:

I have the same problem now - I’ve managed to load the hello app without a problem now, but my own app keeps giving the same error, as you’re describing:

  • I get the overall ‘Streamlit cannot hash an object of type <class ‘os._Environ’>.,’
  • and then the same error for every single function that was using cache: ‘Streamlit failed to hash an object of type <class ‘function’>.,’
  • underneath the warnings is the error call stack - see attached below:

Update: This error is most likely covered here: https://github.com/streamlit/streamlit/issues/242 and as per Thiago’s message earlier today, it has been fixed and should go into prod version over the next couple of days (Blindly following setup instructions)

@gabe_maldonado’s hash issue and @svilupp’s TypeError indeed look like https://github.com/streamlit/streamlit/issues/242 . So those should be fixed soon!

As for the @gabe_maldonado’s issue with port 80, I’m not so sure what’s happening. We fixed a bug related to port 80 a few point-versions ago. So perhaps you’re not running the latest Streamlit? Can you please double-check the version you have?

$ streamlit version

Should be 0.47.4

I have version 0047.4 running on both, Win7 and mac, machines.
I was able to successfully deploy the DataExplorer app on heroku by commenting out the @st.cache decorator.
Commenting out the decorator on macos allows me to load the data and see the dataframe but then I get:

  • TypeError : ‘ellipsis’ object is not iterable*

Also, it is strange that this line of code:
st.subheader(f'Map of all pickups at {hour_to_filter}:00)
works perfectly in Windows but when I run it on the macos I get an ‘invalid syntax’, “unxpected token ‘)’” and an “undefined variable ‘f’” errors.

GM

TypeError : ‘ellipsis’ object is not iterable

This looks like this Altair bug with Python 3.5.1: TypeError: 'ellipsis' object is not iterable · Issue #972 · altair-viz/altair · GitHub

it is strange that this line of code:
st.subheader(f'Map of all pickups at {hour_to_filter}:00)
works perfectly in Windows but when I run it on the macos I get an ‘invalid syntax’, “unxpected token ‘)’” and an “undefined variable ‘f’” errors.

You’re likely using a version of Python that doesn’t support f-strings. Those were added in Python version 3.6.

So your best bet for both of these is just to upgrade Python to a more recent version :smiley:

Interestingly, I get this issue when I access the Streamlit server via its domain name (SERVERHOSTNAME:8501) but not when I access it at it’s IP address (10.X.X.X:8501). I’m running it on Windows Server 2016 in a conda environment.

Hey @antikythera!

Can you try setting the

[browser]
serverAddress = [your server hostname]

setting in your Streamlit config? (Instructions on the config are here: https://streamlit.io/docs/cli.html).

If you’ve already tried this and it’s not working, then it may be a network issue. Are you running it on a local server, or some hosting provider? Do you have a firewall that whitelists only certain types of traffic to certain hostnames? Or perhaps an Ngninx or Apache server acting as a reverse proxy for your Streamlit app, and that has routing rules that may be preventing this from working?

Streamlit serves normal HTTP requests as well as WebSocket requests over its port. Depending on what you’re integrating with, you may need to explicitly enable WebSocket traffic to get Streamlit to work.

Hi,

I’m getting the “please wait” issue as well on ec2 instance. I’ve added the “enableCORS=false” and it has not been resolved.

my nginx is as follows:

    location /study/ {
            proxy_pass http://xx:xx:xxx:xx:8501/;
    }

Any suggestions?

Thanks

Hi @karma,

Did you try these following steps from our FAQ: https://github.com/streamlit/streamlit/wiki/FAQ ?

Thanks @arraydude, the template from @virusvn fixed the issue

I am facing exactly the same problem. I followed this tutorial to deploy to an EC2 instance. I am trying to access the app via the external IP (no domains involved). I am running streamlit hello --server.enableCORS=false but still get stuck in a “Please wait
” screen.

This is how Chrome’s console looks like:

Any ideas?

An update: apparently the issue is specific to Google Chrome. It works just fine on Microsoft Edge :thinking:

1 Like

This is happening to me locally (macOS Catalina 10.15.5) running streamlit hello only on Chrome (streamlit version 0.62.0).

1 Like

Hi @EilonBaer!

Is this happening when running on a server, or when running locally?

If server, can you try the updated instructions from our troubleshooting page?

We recently added websocket compression and XSRF-prevention logic to Streamlit, which should improve app but have the unfortunate side-effect of adding a couple of steps to Streamlit deployments

Hi @thiago, thanks for the reply.

The issue was happening locally, but turned out to be unrelated to streamlit. I had just integrated the SentinalOne Chrome extension and that caused connectivity issues (happened with Jupyter as well). Disabled the extension, all back to normal. Thanks!

1 Like