HOWTO: Streamlit on AWS with Elastic Beanstalk and Docker

Hello all,

Recently deployed a small streamlit app with AWS elastic beanstalk and docker:

streamlit app
source code

Building and testing the app locally with docker and the elastic beanstalk cli was not problem. The real challenge was correctly configuring the app environment once deployed.

There are several threads floating around this corner of the forum that deal with security groups, load balancing, TCP/HTTPS, CORS, ports, sticky sessions, .toml, etc. In addition to that, there are several well written but different tutorials for cloud deployment. For a neophyte, this made it quite challenging to figure out the best approach.

So… this is what worked for me:

  1. Build a streamlit docker container
  2. Expose port 80
  3. Run streamlit with flags:
    –server.enableCORS False
    –server.port 80
  4. In streamlit working directory init and create and elastic beanstalk environment
  5. After deployment success go to elastic beanstalk console in your region on AWS
  6. Find your environment and go to configuration → load balancer
  7. Under load balancer change port 80 from HTTPS to TCP and apply environment settings
  8. Confirm that app is running by accessing the elastic beanstalk url in the console

This approach allowed me to get past the hanging “streamlit connecting” issue after environment launch. The error appeared to be caused by the default HTTPS port listener in the load balancer.

Depending on your app design and needs your mileage may vary on this approach. There are a slew of other complexities when dealing with streamlit and cloud deployment. Trial and error was the only way I could figure it out.

Thanks to @randyzwitch and @ash2shukla for the tips and pointers along the way.



Awesome, glad you got it figured out! Feel free to add this to our deployment wiki:




Glad to contribute to the community.

1 Like

Doesnt seem to work for me. Tried exact steps.