Streamlit not getting AWS public IP

The following lines were my first testing program using AWS EC2 (Window Sever 2019) and streamlit.
The “Network URL” I got was AWS’ Private IPs 172.31.71.27, which can’t be access from outside!
My question is how can Streamlit set the “Network URL” to AWS’ IPv4 Public IP 3.235.195.213, so that everyone can access from the world?
Thank you so much! (After googling, I am so desperately!)

(base) C:\Users\Administrator>streamlit run test.py
Hello, World!

You can now view your Streamlit app in your browser.

Local URL: http://localhost:8501
Network URL: http://172.31.71.27:8501

Hi @Steve_Chen, welcome to the Streamlit community!

The IP address shown by Streamlit is somewhat misleading when deployed on a cloud service like AWS, as it refers to the IP address of the machine on the AWS internal network. What you need to do is go to the AWS console for the machine you started and see what the external IP address is listed by AWS.

Additionally, you need to open the AWS firewall to allow the post you are using to be accessed by the outside world (by default, 8501). AWS and many other cloud providers have machines closed to the outside world by default for security reasons, so that you don’t accidentally provide access that was unintended.

Best,
Randy

Thank you so much Randy. It worked!!!

This is what I have done to solve the issue:

  1. Connect to EC2 instance
  2. Login to Windows VM
  3. In the bottom-left corner of the window, Just right next to the Windows Start icon, there is a search icon, click it.
  4. Type firewall
  5. Click check firewall status
  6. Click the advanced setting
  7. Scroll down and click the inbound rule
  8. On the left panel, right click the Inbound Rules
  9. Click new rule
  10. Create an inbound rule by filling in the protocol type with TCP, port numer: 8501…

Find my public IP in EC2 console: 3.235.195.213
In the browser, type 3.235.195.213:8501
And it connected to the streamlit app that I ran in the server.

It worked!!!

1 Like

Hi @Steve_Chen ,

I’m also running on AWS Windows Server and having the same problem as you were. I tried your solution to add firewall inbound rules to port 8501 and still can’t get streamlit to open on public IP.

Can you give some suggestions ? Am I missing something ?

1 Like