From 9da8f09f22d87a6ea122a5d7e6b9a7510253fa4e Mon Sep 17 00:00:00 2001 From: Krishna Chaitanya Balusu Date: Tue, 24 Mar 2026 22:24:46 -0400 Subject: [PATCH 1/2] fix: use configured backend_host in notify_backend() instead of hardcoded 0.0.0.0 The notify_backend() function was hardcoding "0.0.0.0" as the backend host in the terminal log output, ignoring the backend_host value set in rxconfig.py or passed via --backend-host CLI argument. This change: - Adds an optional `host` parameter to notify_backend() that falls back to config.backend_host when not provided - Passes the resolved host from run_backend() and run_backend_prod() call sites so CLI --backend-host overrides are reflected in logs - Persists the resolved backend_host in the config (via _set_persistent) so it is available to notify_backend() even when called from the frontend thread in run_process_and_launch_url() Fixes #6165 --- reflex/reflex.py | 4 +++- reflex/utils/exec.py | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/reflex/reflex.py b/reflex/reflex.py index cb677c3173e..e5db116854b 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -198,11 +198,13 @@ def _run( auto_increment=auto_increment_backend, ) - # Apply the new ports to the config. + # Apply the new ports and host to the config. if frontend_port != config.frontend_port: config._set_persistent(frontend_port=frontend_port) if backend_port != config.backend_port: config._set_persistent(backend_port=backend_port) + if backend_host != config.backend_host: + config._set_persistent(backend_host=backend_host) # Reload the config to make sure the env vars are persistent. get_config(reload=True) diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index c67976b23b2..9ea77f1b2a7 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -157,10 +157,16 @@ def notify_frontend(url: str, backend_present: bool): ) -def notify_backend(): - """Output a string notifying where the backend is running.""" +def notify_backend(host: str | None = None): + """Output a string notifying where the backend is running. + + Args: + host: The backend host. If not provided, falls back to the config value. + """ + config = get_config() + effective_host = host or config.backend_host 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://{effective_host}:{config.backend_port}[/bold green]" ) @@ -378,7 +384,7 @@ def run_backend( (web_dir / constants.NOCOMPILE_FILE).touch() if not frontend_present: - notify_backend() + notify_backend(host) # Run the backend in development mode. if should_use_granian(): @@ -579,7 +585,7 @@ def run_backend_prod( mount_frontend_compiled_app: Whether to mount the compiled frontend app with the backend. """ if not frontend_present: - notify_backend() + notify_backend(host) environment.REFLEX_MOUNT_FRONTEND_COMPILED_APP.set(mount_frontend_compiled_app) From 0540c697590ecc8757b92d54b5b24b41a061718d Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 26 Mar 2026 12:53:16 -0700 Subject: [PATCH 2/2] Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- reflex/utils/exec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index 9ea77f1b2a7..331dd73c951 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -164,7 +164,7 @@ def notify_backend(host: str | None = None): host: The backend host. If not provided, falls back to the config value. """ config = get_config() - effective_host = host or config.backend_host + effective_host = host if host is not None else config.backend_host console.print( f"Backend running at: [bold green]http://{effective_host}:{config.backend_port}[/bold green]" )