Step 1 : Azure VMs have Network Security Group rules which determine which traffic can reach the VM. By default, only a few ports like 22 (for SSH) are open.
- You need to create an inbound rule to allow traffic on port
8501
. - Go to Azure Portal → Your VM → Networking → Add inbound port rule.
- Source: Any, Source port ranges: *, Destination: Any, Destination port ranges: 8501, Protocol: Any, Action: Allow, Priority: <Choose a unique number between 100 and 4096>, Name: Streamlit8501
Step 2 :
- If you are using an Ubuntu machine for example, you can check using
ufw
:
sudo ufw status
- If
8501
isn't in the list of allowed ports, you can allow it using:
sudo ufw allow 8501
Step 3 : By default, Streamlit only listens on the local network interface (localhost
). If you want it to be accessible from the internet, you may need to bind it to 0.0.0.0
which means it will listen on all network interfaces. Start your Streamlit app like this:
streamlit run Home.py --server.address 0.0.0.0
Exposing your app to the public internet by binding to 0.0.0.0
is risky if you don't have proper security measures in place.
Step 4 : Ensure there aren't any errors in your Home.py
script that might be causing the app to fail. Check the terminal where you ran the streamlit run
command for any errors.
Ensure that all the necessary dependencies and packages are installed and accessible.
Step 5 : Perhaps port 8501
is being used by another service. Try running Streamlit on a different port:
(If it works, don't forget to update the NSG rule in Azure to allow traffic on the new port.)
streamlit run Home.py --server.port 8502