From c0a5f5fdebd0382ddd363d401d1a9bd1c1f0f9ad Mon Sep 17 00:00:00 2001 From: ajaysi Date: Mon, 6 Apr 2026 07:01:02 +0530 Subject: [PATCH] Fix Render port binding - preload_app=False, add early env debug --- backend/app.py | 6 ++++++ backend/gunicorn_config.py | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/app.py b/backend/app.py index 864160e8..668305fd 100644 --- a/backend/app.py +++ b/backend/app.py @@ -1,6 +1,12 @@ # Ensure typing constructs and models are available globally for FastAPI type annotation evaluation +import os + +# Print env vars immediately - BEFORE any imports +print(f"[app.py] EARLY - PORT={os.getenv('PORT')}, HOST={os.getenv('HOST')}", flush=True) + import typing import builtins +import builtins # Make common typing constructs available globally builtins.Optional = typing.Optional diff --git a/backend/gunicorn_config.py b/backend/gunicorn_config.py index 08291d2e..78c67781 100644 --- a/backend/gunicorn_config.py +++ b/backend/gunicorn_config.py @@ -25,8 +25,9 @@ accesslog = "-" errorlog = "-" loglevel = os.getenv("LOG_LEVEL", "info").lower() -# Preload app (set to False for faster startup if needed) -preload_app = True +# Don't preload - bind to port FIRST, then load worker +# This fixes "No open ports detected" on Render +preload_app = False def on_starting(server):