Streamlit application external url is not accessible.

Sumeet Patel 0 Reputation points
2023-09-14T12:31:16.8033333+00:00

Hello support team,

I have followed this page.
https://github.com/neo4j-partners/neo4j-generative-ai-azure/blob/main/README.md

I have created Azure machine learning model and dumped data to neo4j database.
however when I run the below command from the location ~/cloudfiles/code/Users/sumeet/neo4j-generative-ai-azure/ui/streamlit

streamlit run Home.py

It showed me this output

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.

  You can now view your Streamlit app in your browser.

  Network URL: http://10.0.0.5:8501
  External URL: http://20.75.107.185:8501

But when I open [http://20.75.107.185:8501] in my browser is not working.

Does anybody have any idea?

Thanks

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
30,326 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 4,476 Reputation points
    2023-09-18T17:34:08.5+00:00

    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
    
    0 comments No comments