Skip to content

fix: dynamically report backend_host in terminal logs #6165#6177

Open
pranavmanglik wants to merge 2 commits intoreflex-dev:mainfrom
pranavmanglik:fix-backend-host-hardcoding-in-logs
Open

fix: dynamically report backend_host in terminal logs #6165#6177
pranavmanglik wants to merge 2 commits intoreflex-dev:mainfrom
pranavmanglik:fix-backend-host-hardcoding-in-logs

Conversation

@pranavmanglik
Copy link

All Submissions:

Type of change

  • Bug fix (non-breaking change which fixes an issue)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully ran tests with your changes locally?

Pull Request Details

Descriptive Title

fix: accurately report configured backend_host in terminal logs

Description of Changes

Currently, the notify_backend function in reflex/utils/exec.py has the backend IP hardcoded as 0.0.0.0. This leads to misleading terminal output when a user has explicitly configured a custom backend_host (e.g., 127.0.0.1 for local-only development) in their rxconfig.py.

This PR modifies the notification logic to dynamically pull the backend_host from the Reflex configuration, ensuring the logs match the actual network binding. This improves developer clarity and assists in verifying security configurations.

Testing performed:

  • Verified on EndeavourOS by setting backend_host="127.0.0.1" in rxconfig.py.
  • Confirmed terminal output correctly displays http://127.0.0.1:8000 instead of the hardcoded 0.0.0.0.
  • Ensured local linting (ruff) passes.

Closing Issues

Closes #6165

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

Fixes the notify_backend() function in reflex/utils/exec.py to dynamically display the configured backend_host instead of a hardcoded 0.0.0.0 in terminal logs. This ensures developer-facing output matches the actual server binding when a custom host is set in rxconfig.py or via the --backend-host CLI flag.

  • Replaces 0.0.0.0 with get_config().backend_host in the log message
  • Minimal, well-scoped change — only the notification string is affected, not actual server binding logic
  • No new dependencies or architectural changes

Confidence Score: 4/5

  • This PR is safe to merge — it only changes a log message string with no impact on server binding behavior.
  • Score of 4 reflects that this is a trivial, single-line change affecting only terminal output. The get_config().backend_host value is already used elsewhere for actual server binding, so using it in the notification is correct and consistent. Minor style note: get_config() is called twice in one f-string, but this matches the prior pattern and get_config() is cached.
  • No files require special attention.

Important Files Changed

Filename Overview
reflex/utils/exec.py Single-line change in notify_backend() replaces hardcoded 0.0.0.0 with get_config().backend_host so terminal logs reflect the configured backend host. Correct and low-risk.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["rxconfig.py / CLI / Env Var"] -->|"sets backend_host"| B["Config.backend_host"]
    B -->|"used by"| C["run_backend() / run_backend_prod()"]
    C -->|"binds server to"| D["uvicorn / granian / gunicorn"]
    B -->|"displayed by (this PR fix)"| E["notify_backend()"]
    E -->|"prints"| F["Terminal: Backend running at http://host:port"]
Loading

Last reviewed commit: 8d83e61

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 16, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing pranavmanglik:fix-backend-host-hardcoding-in-logs (8d83e61) with main (7607fa3)

Open in CodSpeed

"""Output a string notifying where the backend is running."""
console.print(
f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]"
f"Backend running at: [bold green]http://{get_config().backend_host}:{get_config().backend_port}[/bold green]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of calling get_config() twice, cache the returned config and reference it in both places.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your response, i actually new to open source. I thought about it but then had doubt if it was that necessary as it was being called twice only.

@pranavmanglik pranavmanglik requested a review from masenf March 16, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exec.py: notify_backend() hardcodes 0.0.0.0, backend_host config shows invalid IP in logs

2 participants