Skip to content

Fix #6165: Dynamically report backend_host in terminal logs#6191

Closed
pranavmanglik wants to merge 2 commits intoreflex-dev:mainfrom
pranavmanglik:main
Closed

Fix #6165: Dynamically report backend_host in terminal logs#6191
pranavmanglik wants to merge 2 commits intoreflex-dev:mainfrom
pranavmanglik:main

Conversation

@pranavmanglik
Copy link
Copy Markdown

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
Copy Markdown
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR fixes issue #6165 by dynamically reporting the configured backend_host in terminal logs instead of the hardcoded 0.0.0.0. The intent is correct, but the implementation introduces a critical runtime bug: after calling config = get_config() (which returns a Config instance), the code then invokes config() with parentheses as though config were still a function. This will raise TypeError: 'Config' object is not callable every time notify_backend() is called, making the backend startup notification completely broken.

Key issues:

  • Critical bug: config().backend_host and config().backend_port should be config.backend_host and config.backend_port — attributes accessed on the already-resolved Config object, not a second function call.
  • The fix is a one-character change per reference (removing the () after config), and once corrected the PR achieves its stated goal correctly.

Confidence Score: 1/5

  • Not safe to merge — the change introduces a critical TypeError that will crash the backend startup notification on every run.
  • The PR's goal is valid and the approach is sensible, but a subtle double-invocation bug (config() instead of config) means notify_backend() will always raise TypeError: 'Config' object is not callable. This is a regression that breaks existing working behaviour and must be corrected before merging.
  • reflex/utils/exec.py lines 162–165 — the config() calls must be changed to config. attribute accesses.

Important Files Changed

Filename Overview
reflex/utils/exec.py Introduces a critical runtime TypeError: config = get_config() correctly captures the Config instance, but then config() is called with parentheses as if it were a callable, which will crash notify_backend() every time it is invoked.

Sequence Diagram

sequenceDiagram
    participant Runner as App Runner
    participant Exec as exec.notify_backend()
    participant Config as get_config()

    Runner->>Exec: notify_backend()
    Exec->>Config: get_config()
    Config-->>Exec: Config object (config)
    Note over Exec: BUG: config() called<br/>with parentheses — TypeError!
    Exec->>Exec: config().backend_host ❌
    Exec->>Exec: config().backend_port ❌
    Note over Exec: CORRECT: access attributes directly
    Exec->>Exec: config.backend_host ✅
    Exec->>Exec: config.backend_port ✅
    Exec-->>Runner: console.print("Backend running at: http://{host}:{port}")
Loading

Last reviewed commit: "Fix #6165"

Comment thread reflex/utils/exec.py
Comment on lines +162 to 165
config = get_config()
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://{config().backend_host}:{config().backend_port}[/bold green]"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Config object called as a function — TypeError at runtime

get_config() returns a Config instance, not a callable. Assigning it to config and then invoking config() on line 164 (twice) will raise TypeError: 'Config' object is not callable every time notify_backend() is called.

The attributes should be accessed directly on the object returned by get_config():

Suggested change
config = get_config()
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://{config().backend_host}:{config().backend_port}[/bold green]"
)
config = get_config()
console.print(
f"Backend running at: [bold green]http://{config.backend_host}:{config.backend_port}[/bold green]"
)

Copy link
Copy Markdown
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

why did you make a new PR? the old one was fine and this one is broken

@pranavmanglik pranavmanglik closed this by deleting the head repository Mar 18, 2026
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