Network URL not working on other computers

Summary

When I run streamlit run xxx.py, it works very well in my local browser. When I try to access the web app from another computer using the provided network URL, Streamlit shows:

Safari can’t open the page “http://192.168.1.100:8501”. because the server where this page is located isn’t responding.

Steps to reproduce

  1. streamit run xxxx.py
  2. Local URL: http://localhost:8501 works!
  3. Network URL: http://192.168.1.100:8501 - works on local computer, but not on other computers.

config.toml

[global]

# By default, Streamlit checks if the Python watchdog module is available and, if not, prints a warning asking for you to install it. The watchdog module is not required, but highly recommended. It improves Streamlit's ability to detect changes to files in your filesystem.

# If you'd like to turn off this warning, set this to True.

# Default: false

disableWatchdogWarning = false

# Configure the ability to share apps to the cloud.

# Should be set to one of these values: - "off" : turn off sharing. - "s3" : share to S3, based on the settings under the [s3] section of this config file. - "file" : share to a directory on the local machine. This is meaningful only for debugging Streamlit itself, and shouldn't be used for production.

# Default: "off"

sharingMode = "off"

# If True, will show a warning when you run a Streamlit-enabled script via "python my_script.py".

# Default: true

showWarningOnDirectExecution = true

# Level of logging: 'error', 'warning', 'info', or 'debug'.

# Default: 'info'

logLevel = "info"

[client]

# Whether to enable st.cache.

# Default: true

caching = true

# If false, makes your Streamlit script not draw to a Streamlit app.

# Default: true

displayEnabled = true

[runner]

# Allows you to type a variable or string by itself in a single line of Python code to write it to the app.

# Default: true

magicEnabled = true

# Install a Python tracer to allow you to stop or pause your script at any point and introspect it. As a side-effect, this slows down your script's execution.

# Default: false

installTracer = false

# Sets the MPLBACKEND environment variable to Agg inside Streamlit to prevent Python crashing.

# Default: true

fixMatplotlib = true

[server]

# List of folders that should not be watched for changes. This impacts both "Run on Save" and @st.cache.

# Relative paths will be taken as relative to the current working directory.

# Example: ['/home/user1/env', 'relative/path/to/folder']

# Default: []

folderWatchBlacklist = []

# Change the type of file watcher used by Streamlit, or turn it off completely.

# Allowed values: * "auto" : Streamlit will attempt to use the watchdog module, and falls back to polling if watchdog is not available. * "watchdog" : Force Streamlit to use the watchdog module. * "poll" : Force Streamlit to always use polling. * "none" : Streamlit will not watch files.

# Default: "auto"

fileWatcherType = "auto"

# If false, will attempt to open a browser window on start.

# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) server.liveSave is set.

headless = false

# Immediately share the app in such a way that enables live monitoring, and post-run analysis.

# Default: false

liveSave = false

# Automatically rerun script when the file is modified on disk.

# Default: false

runOnSave = false

# The address where the server will listen for client and browser connections. Use this if you want to bind the server to a specific address. If set, the server will only be accessible from this address, and not from any aliases (like localhost).

# Default: (unset)

#address =

# The port where the server will listen for browser connections.

# Default: 8501

port = 8501

# The base path for the URL where Streamlit should be served from.

# Default: ""

baseUrlPath = ""

# Enables support for Cross-Origin Request Sharing, for added security.

# Default: true

enableCORS = false

# Max size, in megabytes, for files uploaded with the file_uploader.

# Default: 200

maxUploadSize = 200

[browser]

# Internet address where users should point their browsers in order to connect to the app. Can be IP address or DNS name and path.

# This is used to: - Set the correct URL for CORS purposes. - Show the URL on the terminal - Open the browser - Tell the browser where to connect to the server when in liveSave mode.

# Default: 'localhost'

serverAddress = "192.168.1.100"

# Whether to send usage statistics to Streamlit.

# Default: true

gatherUsageStats = true

# Port where users should point their browsers in order to connect to the app.

# This is used to: - Set the correct URL for CORS purposes. - Show the URL on the terminal - Open the browser - Tell the browser where to connect to the server when in liveSave mode.

# Default: whatever value is set in server.port.

serverPort = 8501

[mapbox]

# Configure Streamlit to use a custom Mapbox token for elements like st.deck_gl_chart and st.map. If you don't do this you'll be using Streamlit's own token, which has limitations and is not guaranteed to always work. To get a token for yourself, create an account at https://mapbox.com. It's free! (for moderate usage levels)

# Default: ""

token = ""

[s3]

# Name of the AWS S3 bucket to save apps.

# Default: (unset)

#bucket =

# URL root for external view of Streamlit apps.

# Default: (unset)

#url =

# Access key to write to the S3 bucket.

# Leave unset if you want to use an AWS profile.

# Default: (unset)

#accessKeyId =

# Secret access key to write to the S3 bucket.

# Leave unset if you want to use an AWS profile.

# Default: (unset)

#secretAccessKey =

# The "subdirectory" within the S3 bucket where to save apps.

# S3 calls paths "keys" which is why the keyPrefix is like a subdirectory. Use "" to mean the root directory.

# Default: ""

keyPrefix = ""

# AWS region where the bucket is located, e.g. "us-west-2".

# Default: (unset)

#region =

# AWS credentials profile to use.

# Leave unset to use your default profile.

# Default: (unset)

#profile =

Welcome to the community @TheClub4!

Usually an issue like this indicates a networking issue, not a Streamlit one. If there is a firewall on the computer you are trying to access over the network, temporarily disabling it completely will allow you to understand if that’s the issue.

If disabling the firewall works, then you can re-enable the firewall with a rule that allows access to port 8501. How this is done depends on which operating system you are using and your local network setup, so unfortunately I can’t give too much more detail than that.

Im getting the same problem; tried to disable the firewall on my machine. I’m using windows-7.

Anybody can help me out

Having this same issue on a home network with OSX… any luck? I have no firewall enabled.

On ubuntu, I could do sudo ufw disable and it worked.

I would recommend doing a ping to the ip you are trying to reach. If you can ie ping -c 4 192.168.1.106 without problems, and the streamlit app is running locally, then it is definitely a firewall issue.

1 Like

Having faced the same issue and spending 4 hrs on figuring it out. Follow this:
streamlit picks up configuration from config.toml file. But the default is not created. Follow this to set up:

sudo mkdir .streamlit
sudo touch config.toml
sudo chown root:root config.toml
sudo chmod 775 config.toml
vi config.toml

add the below configuration:

# Below are all the sections and options you can have in ~/.streamlit/config.toml.

[global]

# By default, Streamlit checks if the Python watchdog module is available and, if not, prints a warning asking for you to install it. The watchdog module is not required, but highly recommended. It improves Streamlit's ability to detect changes to files in your filesystem.
# If you'd like to turn off this warning, set this to True.
# Default: false
# The value below was set in /home/amit/.streamlit/config.toml
disableWatchdogWarning = false

# If True, will show a warning when you run a Streamlit-enabled script via "python my_script.py".
# Default: true
# The value below was set in /home/amit/.streamlit/config.toml
showWarningOnDirectExecution = true

# DataFrame serialization.
# Acceptable values: - 'legacy': Serialize DataFrames using Streamlit's custom format. Slow but battle-tested. - 'arrow': Serialize DataFrames using Apache Arrow. Much faster and versatile.
# Default: "arrow"
# The value below was set in /home/amit/.streamlit/config.toml
dataFrameSerialization = "arrow"


[logger]

# Level of logging: 'error', 'warning', 'info', or 'debug'.
# Default: 'info'
# The value below was set in /home/amit/.streamlit/config.toml
level = "info"

# String format for logging messages. If logger.datetimeFormat is set, logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See [Python's documentation](https://docs.python.org/2.6/library/logging.html#formatter-objects) for available attributes.
# Default: "%(asctime)s %(message)s"
# The value below was set in /home/amit/.streamlit/config.toml
messageFormat = "%(asctime)s %(message)s"


[client]

# Whether to enable st.cache.
# Default: true
# The value below was set in /home/amit/.streamlit/config.toml
caching = true

# If false, makes your Streamlit script not draw to a Streamlit app.
# Default: true
# The value below was set in /home/amit/.streamlit/config.toml
displayEnabled = true

# Controls whether uncaught app exceptions are displayed in the browser. By default, this is set to True and Streamlit displays app exceptions and associated tracebacks in the browser.
# If set to False, an exception will result in a generic message being shown in the browser, and exceptions and tracebacks will be printed to the console only.
# Default: true
# showErrorDetails = true


[runner]

# Allows you to type a variable or string by itself in a single line of Python code to write it to the app.
# Default: true
# The value below was set in /home/amit/.streamlit/config.toml
magicEnabled = true

# Install a Python tracer to allow you to stop or pause your script at any point and introspect it. As a side-effect, this slows down your script's execution.
# Default: false
# The value below was set in /home/amit/.streamlit/config.toml
installTracer = false

# Sets the MPLBACKEND environment variable to Agg inside Streamlit to prevent Python crashing.
# Default: true
# The value below was set in /home/amit/.streamlit/config.toml
fixMatplotlib = true

# Run the Python Garbage Collector after each script execution. This can help avoid excess memory use in Streamlit apps, but could introduce delay in rerunning the app script for high-memory-use applications.
# Default: true
# postScriptGC = true

# Handle script rerun requests immediately, rather than waiting for script execution to reach a yield point. Enabling this will make Streamlit much more responsive to user interaction, but it can lead to race conditions in apps that mutate session_state data outside of explicit session_state assignment statements.
# Default: false
# fastReruns = false


[server]

# List of folders that should not be watched for changes. This impacts both "Run on Save" and @st.cache.
# Relative paths will be taken as relative to the current working directory.
# Example: ['/home/user1/env', 'relative/path/to/folder']
# Default: []
# The value below was set in /home/amit/.streamlit/config.toml
folderWatchBlacklist = []

# Change the type of file watcher used by Streamlit, or turn it off completely.
# Allowed values: * "auto" : Streamlit will attempt to use the watchdog module, and falls back to polling if watchdog is not available. * "watchdog" : Force Streamlit to use the watchdog module. * "poll" : Force Streamlit to always use polling. * "none" : Streamlit will not watch files.
# Default: "auto"
# The value below was set in /home/amit/.streamlit/config.toml
fileWatcherType = "auto"

# Symmetric key used to produce signed cookies. If deploying on multiple replicas, this should be set to the same value across all replicas to ensure they all share the same secret.
# Default: randomly generated secret key.
# cookieSecret = "9c87f574f4564cbe8d08371eec795da11a0e78650656f47399ebc459e9f7bf8e"

# If false, will attempt to open a browser window on start.
# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) we are running in the Streamlit Atom plugin.
# The value below was set in /home/amit/.streamlit/config.toml
headless = true

# Automatically rerun script when the file is modified on disk.
# Default: false
# The value below was set in /home/amit/.streamlit/config.toml
runOnSave = false

# The address where the server will listen for client and browser connections. Use this if you want to bind the server to a specific address. If set, the server will only be accessible from this address, and not from any aliases (like localhost).
# Default: (unset)
# address =

# The port where the server will listen for browser connections.
# Default: 8501
# The value below was set in /home/amit/.streamlit/config.toml
port = 8501

# The base path for the URL where Streamlit should be served from.
# Default: ""
# The value below was set in /home/amit/.streamlit/config.toml
baseUrlPath = ""

# Enables support for Cross-Origin Request Sharing (CORS) protection, for added security.
# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and `server.enableCORS` is off at the same time, we will prioritize `server.enableXsrfProtection`.
# Default: true
# enableCORS = true

# Enables support for Cross-Site Request Forgery (XSRF) protection, for added security.
# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and `server.enableCORS` is off at the same time, we will prioritize `server.enableXsrfProtection`.
# Default: true
# enableXsrfProtection = true

# Max size, in megabytes, for files uploaded with the file_uploader.
# Default: 200
# maxUploadSize = 200

# Max size, in megabytes, of messages that can be sent via the WebSocket connection.
# Default: 200
# maxMessageSize = 200

# Enables support for websocket compression.
# Default: false
# enableWebsocketCompression = false


[browser]

# Internet address where users should point their browsers in order to connect to the app. Can be IP address or DNS name and path.
# This is used to: - Set the correct URL for CORS and XSRF protection purposes. - Show the URL on the terminal - Open the browser
# Default: 'localhost'
# The value below was set in /home/amit/.streamlit/config.toml
serverAddress = "localhost"

# Whether to send usage statistics to Streamlit.
# Default: true
# The value below was set in /home/amit/.streamlit/config.toml
gatherUsageStats = true

# Port where users should point their browsers in order to connect to the app.
# This is used to: - Set the correct URL for CORS and XSRF protection purposes. - Show the URL on the terminal - Open the browser
# Default: whatever value is set in server.port.
# The value below was set in /home/amit/.streamlit/config.toml
serverPort = 8501


[mapbox]

# Configure Streamlit to use a custom Mapbox token for elements like st.pydeck_chart and st.map. To get a token for yourself, create an account at https://mapbox.com. It's free (for moderate usage levels)!
# Default: ""
# token = ""


[deprecation]

# Set to false to disable the deprecation warning for the file uploader encoding.
# Default: true
# showfileUploaderEncoding = true

# Set to false to disable the deprecation warning for using the global pyplot instance.
# Default: true
# showPyplotGlobalUse = true


[theme]

# The preset Streamlit theme that your custom theme inherits from. One of "light" or "dark".
# base =

# Primary accent color for interactive elements.
# primaryColor =

# Background color for the main content area.
# backgroundColor =

# Background color used for the sidebar and most interactive widgets.
# secondaryBackgroundColor =

# Color used for almost all text.
# textColor =

# Font family for all text in the app, except code blocks. One of "sans serif", "serif", or "monospace".
# font =

:w !chmod 777 %
Then make some changes to the file, it warns you its read only. Use this command.
:w !chmod 777 %
**then write the file **
:wq!

Now adapt to the changes at the project level by:

streamlit config show > app/web_app/.streamlit/config.toml

And then run the app …
I hope this solves the problem

1 Like

For me the issue got solved by doing two things.

  1. This is for my ubuntu VM.
  2. i am adding firewall rule on port 8501 to allow connection request to my ubuntu vm.
  3. if above step resolves the issue, if not then we have to dig deeper and check the iptables
  4. Check for testing purpose by flushing the iptables - sudo iptables -F. FYI doing this resolved my issue. now you can add back you required iptable rules as required