Can't open locally hosted streamlit app on browser

Hi, a beginner here, need help

Trying to run the locally hosted streamlit app but not able to open in browser

Error on browser

This site can’t be reached

localhost refused to connect.




Microsoft Windows [Version 10.0.19045.3570]
(c) Microsoft Corporation. All rights reserved.


E:>mkdir chatbot_project
A subdirectory or file chatbot_project already exists.

E:>cd chatbot_projectstreamlit run
The system cannot find the path specified.

E:>cd chatbot_project

E:\chatbot_project>streamlit run
‘streamlit’ is not recognized as an internal or external command,
operable program or batch file.


(venv) E:\chatbot_project>streamlit run

  Welcome to Streamlit!

  If you’d like to receive helpful onboarding emails, news, offers, promotions,
  and the occasional swag, please enter your email address below. Otherwise,
  leave this field blank.

Notepad code

import streamlit as st

st.set_option(‘server.port’, 8502)

def main():
st.title(“Chatbot UI”)
user_input = st.text_input(“Enter your message:”)

if name == “main”:

How can that possibly work? By the time st.set_option('server.port', 8502) is executed, the server has already started. And you would need to change the code to make it run in a different port.

Besides, the welcome message suggest me that your streamlit is quite old. In a recent version you would get this (IP redacted):

(venv) E:\chatbot_project>streamlit run

  You can now view your Streamlit app in your browser.

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

2023-11-17 09:40:24.250 Uncaught app exception
Traceback (most recent call last):
  File "E:\chatbot_project\venv\Lib\site-packages\streamlit\runtime\scriptrunner\", line 534, in _run_script
    exec(code, module.__dict__)
  File "E:\chatbot_project\", line 3, in <module>
    st.set_option('server.port', 8502)
  File "E:\chatbot_project\venv\Lib\site-packages\streamlit\runtime\", line 396, in wrapped_func
    result = non_optional_func(*args, **kwargs)
  File "E:\chatbot_project\venv\Lib\site-packages\streamlit\", line 124, in set_user_option
    raise StreamlitAPIException(
streamlit.errors.StreamlitAPIException: server.port cannot be set on the fly. Set as command line option, e.g. streamlit run --server.port, or in config.toml instead.

Hi really appreciate your response. I’ve edited the code based on what I understand from your reply. Still can’t access in browser


(venv) E:\chatbot_project>streamlit --version
Streamlit, version 1.28.2

it says requirement already satisfied

My new notepad code

import streamlit as st

def main():
st.title(“Chatbot Streamlit App”)

user_input = st.text_input(“Enter your message:”)

if st.button(“Send”):
chatbot_response = get_chatbot_response(user_input)
st.text_area(“Chatbot Response:”, chatbot_response, height=100)

def get_chatbot_response(user_input):
return "Chatbot: Hello! I’m a simple chatbot. You said: " + user_input

if name == “main”:

The code looks right and “can’t access in browser” doesn’t really tell much about what is going on. Are there any error messages?

Thank you for your assistance. At the moment, I’ve identified an alternative solution. I appreciate your help.