Hosting Streamlit with AWS EC2

I was wondering how to host Streamlit app in the cloud so that I could share it among my friends. I choose AWS EC2 to do this and well I was able to get in online. If anyone is interested how I did it I wrote post here:

This was my first time using AWS EC2 so it might not be the fastest way but its working for me.

Any feedback is appreciated.

8 Likes

Awesome! We’ve been meaning to write something about this the Streamlit docs, but we’re a bit busy with this whole launch thing at the moment :wink:

Thanks for writing this!

Linking similar topic here - Ec2 streamlit stuck on loading screen while running streamlit hello , as there are a few of us who can’t seem to get streamlit on EC2 to work.

I’ve tried the above mentioned tutorial with no success (“Please wait…” loading problem).

Hi again @svilupp! :slight_smile: Ddi you try setting

[server]
enableCORS=false

in your ~/.streamlit/config.toml as described here?

Update: Oh yes. I see that you did. Sorry for missing that! I suggest submitting a bug report, which will give the eng team a lot of useful information about your exact setup.

As per the thread linked in your post, it gradually started working without any changes on my side - makes me wonder whether it was an AWS glitch… I’ll post an update tmrw morning in the related post.

Update: It doesn’t work again (despite no changes on my side).

Hi @svilupp, were you able to get this to work? I am running into a similar situation. But in my case, I only get the “Please wait …” loading problem when I am pointing to the domain name, but if I connect via IP address it works fine. I have the config.toml file but that did not help.

1 Like

Actually, the config.toml setting appears to be working now - several minutes after creating that file and restarting the app.

@thiago I was successful deploying locally using the config.toml guide to redirect to port 80. Before changing the config.toml file on AWS, it worked fine on port 8501. After I changed the config.toml file on AWS, I got the following error. Do you know how to fix it?

Guide to change port:
https://docs.streamlit.io/en/stable/streamlit_configuration.html#set-configuration-options

Terminal Error:

ubuntu@ip-172-31-81-27:~/cr2-cigar-recommender$ streamlit run app.py
Traceback (most recent call last):
  File "/home/ubuntu/miniconda/bin/streamlit", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/streamlit/cli.py", line 191, in main_run
    _main_run(target, args, flag_options=kwargs)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/streamlit/cli.py", line 219, in _main_run
    bootstrap.run(file, command_line, args, flag_options)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/streamlit/bootstrap.py", line 357, in run
    server.start(_on_server_start)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/streamlit/server/server.py", line 306, in start
    start_listening(app)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/streamlit/server/server.py", line 160, in start_listening
    start_listening_tcp_socket(http_server)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/streamlit/server/server.py", line 179, in start_listening_tcp_socket
    http_server.listen(port, address)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/tornado/tcpserver.py", line 151, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/ubuntu/miniconda/lib/python3.9/site-packages/tornado/netutil.py", line 161, in bind_sockets
    sock.bind(sockaddr)
PermissionError: [Errno 13] Permission denied
ubuntu@ip-172-31-81-27:~/cr2-cigar-recommender$ 

Hii! I have deployed streamlit app on AWS EC2 instance- Ubuntu 20.04 box (free tier). but the links I m getting are not working
Can anybody help plz…it would be highly appreciated

Does the app needs to connect to Internet while running the app? If so how do we get all files without intenet?