Streamlit stopped using localhost

I am using streamlit in a docker container. And I am exposing port 8501 to use the app. However, all of a sudden streamlit stopped using localhost and instead uses some IP addresses

docker run -p 8501:8501 -it msmint/msmint:latest

  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.2:8501
  External URL: http://96.51.142.239:8501

Now, I cannot use the app anymore. Why was the old behaviour changed and how can I get it back?

Hey @Soren

The addresses that Streamlit prints to the console don’t really matter. They’re just there to help you find the right address for your machine.

How that works: when we detect that you’re running on a headless server (i.e. a Linux machine without a DISPLAY environment variable) we make Streamlit not open a browser window automatically and also not print “localhost” to the screen. Instead it prints the machine’s local-network-level IP address as well as its internet-level IP address. Again, this is just a change to what gets printed to the screen. There are no other logic changes.

Can you test your docker setup by running python -m http.server 8501 in your container (instead of Streamlit) and seeing if you get something in your browser when you go to localhost:8501 ?

2 Likes

Ok, my bad. I had a port-forwarding activated. So, I was listening to a different computer’s port…