From 478e3c57dd1bb992ce08b0c0505b93bb66f08c2c Mon Sep 17 00:00:00 2001 From: Paul Payne Date: Tue, 30 Jun 2026 21:06:08 -0700 Subject: [PATCH] Health check: treat 3xx as up (gateway :port now redirects) The HTTP health poller marked anything >=300 as down. With subdomain routing the gateway's : health path returns 302 (redirect to the dashboard subdomain), so castle-gateway showed "down" despite being healthy. Accept <400: a 2xx or 3xx means the server answered; only 4xx/5xx (or a connection error) is down. --- castle-api/src/castle_api/health.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/castle-api/src/castle_api/health.py b/castle-api/src/castle_api/health.py index d6e6df1..60db447 100644 --- a/castle-api/src/castle_api/health.py +++ b/castle-api/src/castle_api/health.py @@ -46,7 +46,9 @@ async def _check_http(client: httpx.AsyncClient, name: str, url: str) -> HealthS try: resp = await client.get(url) latency = int((time.monotonic() - start) * 1000) - if resp.status_code < 300: + # 2xx/3xx = the server answered (a 3xx redirect still means it's alive — + # e.g. the gateway's : now redirects to the dashboard subdomain). + if resp.status_code < 400: return HealthStatus(id=name, status="up", latency_ms=latency) return HealthStatus(id=name, status="down", latency_ms=latency) except httpx.HTTPError: