[fix] Display wildcard addresses as localhost in URLs#13720
[fix] Display wildcard addresses as localhost in URLs#13720sfc-gh-nbellante merged 3 commits intodevelopfrom
Conversation
When running Streamlit with --server.address=0.0.0.0, the displayed URL was http://0.0.0.0:8501 which doesn't work on Windows and is generally not useful since 0.0.0.0 is a wildcard address meaning "bind to all interfaces" - not a navigable address. Added get_display_address() utility that translates wildcard addresses (0.0.0.0, ::) to localhost for display/browser purposes. The actual server binding remains unchanged. Fixes #13712
✅ PR preview is ready!
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
SummaryThis PR fixes an issue where wildcard addresses ( Changes:
Code QualityThe implementation is clean and follows existing patterns in the codebase:
No issues identified. Test CoverageThe test coverage is comprehensive and well-structured:
Observation: There are no tests specifically for the
Backwards CompatibilityNo breaking changes. This PR only affects the display/UI layer:
Security & RiskNo security concerns identified.
RecommendationsThe PR is well-implemented with no required changes. Minor observations:
VerdictAPPROVED: The PR correctly fixes the URL display issue for wildcard addresses with clean implementation, comprehensive test coverage, and no backwards compatibility concerns. This is an automated AI review using |
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #13712 where wildcard IP addresses (0.0.0.0 and ::) displayed in URLs don't work in browsers on Windows. The solution translates wildcard addresses to "localhost" for display purposes while keeping the actual server binding unchanged.
Changes:
- Added a new utility function
get_display_address()to translate wildcard addresses to "localhost" - Updated URL display logic in
bootstrap.pyto use the translated addresses for both console output and browser opening - Added comprehensive unit tests for the new functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/streamlit/web/server/server_util.py | Added get_display_address() function to translate wildcard addresses (0.0.0.0, ::) to "localhost" |
| lib/streamlit/web/bootstrap.py | Updated URL printing and browser opening logic to use display-friendly addresses |
| lib/tests/streamlit/web/server/server_util_test.py | Added parameterized tests for get_display_address() function |
| lib/tests/streamlit/web/bootstrap_test.py | Added tests verifying wildcard addresses are displayed as localhost in URLs |
Co-authored-by: Copilot <[email protected]>
|
If you start streamlit without specifing an address, it will use 0.0.0.0 and show a local and network URL: We might want to do the same in case of these wildcards to indicate that the server is also exposed on the given IP. |
When server.address is explicitly set to a wildcard address, show both Local URL and Network URL instead of just a single URL. This makes the output consistent with the default behavior where no address is specified.

Describe your changes
Improved URL display for wildcard IP addresses. When using wildcard addresses like "0.0.0.0" or "::" for the server, these are now displayed as "localhost" in the browser URL and console output. This makes the URLs more user-friendly and avoids confusion, as wildcard addresses aren't directly accessible in browsers on all platforms.
This closes #13712
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.