From 51150a3ed1db79c33d8c08706345a03c41b61ddd Mon Sep 17 00:00:00 2001 From: Cokodayo <78474654+CaptainJack2491@users.noreply.github.com> Date: Mon, 6 Oct 2025 17:09:40 +0100 Subject: [PATCH] fix(ml): Resolve IPv6 startup crash and healthcheck failure (#22387) * fix(ml): Resolve IPv6 startup crash and healthcheck failure Fixes #13782 * fix(ml): updated the fix to use the std lib * Apply code formatting to __main__.py --- machine-learning/immich_ml/__main__.py | 8 +++++++- machine-learning/scripts/healthcheck.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/machine-learning/immich_ml/__main__.py b/machine-learning/immich_ml/__main__.py index d15b0fb321..f453dda0c5 100644 --- a/machine-learning/immich_ml/__main__.py +++ b/machine-learning/immich_ml/__main__.py @@ -1,6 +1,7 @@ import os import signal import subprocess +from ipaddress import ip_address from pathlib import Path from .config import log, non_prefixed_settings, settings @@ -12,6 +13,11 @@ else: module_dir = Path(__file__).parent +bind_host = non_prefixed_settings.immich_host +if ip_address(bind_host).version == 6: + bind_host = f"[{bind_host}]" +bind_address = f"{bind_host}:{non_prefixed_settings.immich_port}" + try: with subprocess.Popen( [ @@ -24,7 +30,7 @@ try: "-c", module_dir / "gunicorn_conf.py", "-b", - f"{non_prefixed_settings.immich_host}:{non_prefixed_settings.immich_port}", + bind_address, "-w", str(settings.workers), "-t", diff --git a/machine-learning/scripts/healthcheck.py b/machine-learning/scripts/healthcheck.py index 82c6cad790..97527290c7 100644 --- a/machine-learning/scripts/healthcheck.py +++ b/machine-learning/scripts/healthcheck.py @@ -1,5 +1,6 @@ import os import sys +from ipaddress import ip_address import requests @@ -7,6 +8,7 @@ port = os.getenv("IMMICH_PORT", 3003) host = os.getenv("IMMICH_HOST", "0.0.0.0") host = "localhost" if host == "0.0.0.0" else host +host = f"[{host}]" if ip_address(host).version == 6 else host try: response = requests.get(f"http://{host}:{port}/ping", timeout=2)