Fix Streamlit Windows deployment by removing 0.0.0.0 server address#351
Conversation
On Windows, 0.0.0.0 is not a valid connect address — the browser fails to open http://0.0.0.0:8501. By removing the address entry from the bundled .streamlit/config.toml, Streamlit defaults to localhost, which works correctly for local deployments. Docker deployments are unaffected as they pass --server.address 0.0.0.0 on the command line. https://claude.ai/code/session_016amsLCZeFogTksmtk1geb5
📝 WalkthroughWalkthroughThe pull request adds steps to GitHub Actions workflows that remove server address configurations from Streamlit config files during Windows executable builds, and updates documentation to describe this configuration adjustment. This ensures Windows deployments default to localhost. Changes
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/build-windows-executable-app.yaml (1)
314-316: Tighten the filter to the actual TOML assignment.
'^address'is looser than necessary: it misses indented keys and can also strip unrelated keys that merely start withaddress. Matching the assignment itself is safer here.Suggested change
- (Get-Content streamlit_exe/.streamlit/config.toml) -notmatch '^address' | Set-Content streamlit_exe/.streamlit/config.toml + (Get-Content streamlit_exe/.streamlit/config.toml) -notmatch '^\s*address\s*=' | Set-Content streamlit_exe/.streamlit/config.toml🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/build-windows-executable-app.yaml around lines 314 - 316, Update the PowerShell filter used with Get-Content/.../Set-Content so it only removes lines that are actual TOML assignments for the server address (not any key that merely starts with "address"); replace the loose regex '^address' in the pipeline with a pattern that matches optional leading whitespace, the exact key, optional whitespace and an equals sign (e.g. '^\s*address\s*=') so lines like indented "address = ..." are removed while other keys are preserved; keep the same Get-Content | -notmatch | Set-Content flow and test with various indentation cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/win_exe_with_embed_py.md`:
- Around line 99-103: The documented PowerShell command targets the wrong path;
update the command that currently references
"streamlit_exe/.streamlit/config.toml" so it points to the actual bundle
directory created earlier (i.e., the ../streamlit_exe/.streamlit/config.toml
location used in previous steps) so the remove-address pipeline runs against the
file created in the earlier steps and not a non-existent local path.
---
Nitpick comments:
In @.github/workflows/build-windows-executable-app.yaml:
- Around line 314-316: Update the PowerShell filter used with
Get-Content/.../Set-Content so it only removes lines that are actual TOML
assignments for the server address (not any key that merely starts with
"address"); replace the loose regex '^address' in the pipeline with a pattern
that matches optional leading whitespace, the exact key, optional whitespace and
an equals sign (e.g. '^\s*address\s*=') so lines like indented "address = ..."
are removed while other keys are preserved; keep the same Get-Content |
-notmatch | Set-Content flow and test with various indentation cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8d9d17a9-a2fe-4730-acd9-94a65a03fc20
📒 Files selected for processing (4)
.github/workflows/build-windows-executable-app.yaml.github/workflows/test-win-exe-w-embed-py.yamldocs/win_exe_with_embed_py.mddocs/win_exe_with_pyinstaller.md
| 3. Remove the server address from the bundled config to use `localhost` (default) instead of `0.0.0.0`, which doesn't work as a connect address on Windows: | ||
|
|
||
| ```powershell | ||
| (Get-Content streamlit_exe/.streamlit/config.toml) -notmatch '^address' | Set-Content streamlit_exe/.streamlit/config.toml | ||
| ``` |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n docs/win_exe_with_embed_py.md | sed -n '82,110p'Repository: OpenMS/streamlit-template
Length of output: 1270
Fix the path in this documented command.
Line 102 uses streamlit_exe/.streamlit/config.toml, but all previous steps (lines 82–97) create and populate ../streamlit_exe. The command targets the wrong path and will fail if the user follows the instructions sequentially from the same working directory.
Suggested change
- (Get-Content streamlit_exe/.streamlit/config.toml) -notmatch '^address' | Set-Content streamlit_exe/.streamlit/config.toml
+ (Get-Content ../streamlit_exe/.streamlit/config.toml) -notmatch '^address' | Set-Content ../streamlit_exe/.streamlit/config.toml🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/win_exe_with_embed_py.md` around lines 99 - 103, The documented
PowerShell command targets the wrong path; update the command that currently
references "streamlit_exe/.streamlit/config.toml" so it points to the actual
bundle directory created earlier (i.e., the
../streamlit_exe/.streamlit/config.toml location used in previous steps) so the
remove-address pipeline runs against the file created in the earlier steps and
not a non-existent local path.
Summary
This PR fixes Streamlit app connectivity issues on Windows by removing the
0.0.0.0server address from bundled configurations and replacing it with the defaultlocalhostaddress, which is the only address that works reliably for local connections on Windows.Key Changes
win_exe_with_embed_py.mdandwin_exe_with_pyinstaller.md): Added instructions for removing the server address configuration from the bundled Streamlit config file using PowerShell.github/workflows/build-windows-executable-app.yamland.github/workflows/test-win-exe-w-embed-py.yaml): Automated the removal of theaddressconfiguration line during the build process to ensure all Windows executables use the correct default localhost addressImplementation Details
The fix uses a PowerShell command to filter out lines matching
^addressfrom the.streamlit/config.tomlfile:This approach:
address = 0.0.0.0configuration that may have been setlocalhostbinding, which works correctly on Windowshttps://claude.ai/code/session_016amsLCZeFogTksmtk1geb5
Summary by CodeRabbit
Release Notes
Documentation
Chores