Skip to content

High performance self-hosted photo and video management solution.

fix(ml): ipv6 check (#22735)

Mert527010792682
diff --git a/machine-learning/immich_ml/__main__.py b/machine-learning/immich_ml/__main__.py
index f453dda0c5..8d575a58d5 100644
--- a/machine-learning/immich_ml/__main__.py
+++ b/machine-learning/immich_ml/__main__.py
@@ -13,8 +13,16 @@ else:
module_dir = Path(__file__).parent
+
+def is_ipv6(host: str) -> bool:
+ try:
+ return ip_address(host).version == 6
+ except ValueError:
+ return False
+
+
bind_host = non_prefixed_settings.immich_host
-if ip_address(bind_host).version == 6:
+if is_ipv6(bind_host):
bind_host = f"[{bind_host}]"
bind_address = f"{bind_host}:{non_prefixed_settings.immich_port}"
diff --git a/machine-learning/scripts/healthcheck.py b/machine-learning/scripts/healthcheck.py
index 97527290c7..38c0a522f1 100644
--- a/machine-learning/scripts/healthcheck.py
+++ b/machine-learning/scripts/healthcheck.py
@@ -7,8 +7,16 @@ import requests
port = os.getenv("IMMICH_PORT", 3003)
host = os.getenv("IMMICH_HOST", "0.0.0.0")
+
+def is_ipv6(host: str) -> bool:
+ try:
+ return ip_address(host).version == 6
+ except ValueError:
+ return False
+
+
host = "localhost" if host == "0.0.0.0" else host
-host = f"[{host}]" if ip_address(host).version == 6 else host
+host = f"[{host}]" if is_ipv6(host) else host
try:
response = requests.get(f"http://{host}:{port}/ping", timeout=2)