# Can't open locally hosted streamlit app on browser

**URL:** <https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636>\
**Category:** Using Streamlit\
**Created:** [November 17, 2023, 8:20am UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636 "2023-11-17T08:20:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shafiq\_Irusath](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/shafiq_irusath/32/28066_2.png) [@Shafiq\_Irusath](https://discuss.streamlit.io/u/Shafiq_Irusath)\
**Post date:** [November 17, 2023, 8:20am UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/1 "2023-11-17T08:20:35Z")

</div>

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.

Try:

- Checking the connection
- Checking the proxy and the firewall

ERR\_CONNECTION\_REFUSED

**Command**

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

C:\Users\User\>E:

E:\>mkdir chatbot\_project  
A subdirectory or file chatbot\_project already exists.

E:\>cd chatbot\_projectstreamlit run streamlit\_app.py  
The system cannot find the path specified.

E:\>cd chatbot\_project

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

E:\chatbot\_project\>.\venv\Scripts\activate

(venv) E:\chatbot\_project\>streamlit run streamlit\_app.py

```
  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:”)  
st.button(“Send”)

if **name** == “ **main** ”:  
main()

---

<div class="post-metadata">

**Author:** ![Goyo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/goyo/32/28219_2.png) [@Goyo](https://discuss.streamlit.io/u/Goyo)\
**Post date:** [November 17, 2023, 8:52am UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/2 "2023-11-17T08:52:44Z")

</div>

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):

```auto
(venv) E:\chatbot_project>streamlit run streamlit_app.py

  You can now view your Streamlit app in your browser.

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

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\script_runner.py", line 534, in _run_script
    exec(code, module. __dict__ )
  File "E:\chatbot_project\streamlit_app.py", line 3, in <module>
    st.set_option('server.port', 8502)
  File "E:\chatbot_project\venv\Lib\site-packages\streamlit\runtime\metrics_util.py", line 396, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\chatbot_project\venv\Lib\site-packages\streamlit\config.py", 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 script.py --server.port, or in config.toml instead.

```

---

<div class="post-metadata">

**Author:** ![Shafiq\_Irusath](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/shafiq_irusath/32/28066_2.png) [@Shafiq\_Irusath](https://discuss.streamlit.io/u/Shafiq_Irusath)\
**Post date:** [November 17, 2023, 9:55am UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/3 "2023-11-17T09:55:27Z")

</div>

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

**Command**

(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** ”:  
main()

---

<div class="post-metadata">

**Author:** ![Goyo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/goyo/32/28219_2.png) [@Goyo](https://discuss.streamlit.io/u/Goyo)\
**Post date:** [November 17, 2023, 11:27am UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/4 "2023-11-17T11:27:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Shafiq\_Irusath](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/shafiq_irusath/32/28066_2.png) [@Shafiq\_Irusath](https://discuss.streamlit.io/u/Shafiq_Irusath)\
**Post date:** [November 28, 2023, 8:45am UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/5 "2023-11-28T08:45:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![naveen\_yadav](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/naveen_yadav/32/28679_2.png) [@naveen\_yadav](https://discuss.streamlit.io/u/naveen_yadav)\
**Post date:** [February 1, 2024, 9:57pm UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/6 "2024-02-01T21:57:53Z")

</div>

can you please help me with this , i m also geeting same thing in terminal  
PS C:\Users\Naveen\PycharmProjects\Email\sms-classifier\> streamlit run app.py

```
  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.

  Email:

```

---

<div class="post-metadata">

**Author:** ![Oscar1](https://avatars.discourse-cdn.com/v4/letter/o/35a633/32.png) [@Oscar1](https://discuss.streamlit.io/u/Oscar1)\
**Post date:** [February 1, 2024, 10:04pm UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/7 "2024-02-01T22:04:36Z")

</div>

Hi,

you can enter your e.mail or if you don’t want to press enter and welcome.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [July 30, 2024, 10:05pm UTC](https://discuss.streamlit.io/t/cant-open-locally-hosted-streamlit-app-on-browser/55636/8 "2024-07-30T22:05:08Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
