blakeblackshear/frigate · error · RuntimeError

Failed to download model from {url}: {str(e)}

Error message

Failed to download model from {url}: {str(e)}

What it means

urllib.request.urlretrieve raised while downloading the Hailo .hef model (DNS failure, HTTP 403/404, TLS error, or a socket timeout). The original exception is chained into a RuntimeError with the URL and cause, surfaced from check_and_prepare during detector init.

Source

Thrown at frigate/detectors/plugins/hailo8l.py:306

        if path and path.endswith(".hef"):
            return os.path.basename(path)
        elif url and url.endswith(".hef"):
            return os.path.basename(url)
        else:
            if ARCH == "hailo8":
                return H8_DEFAULT_MODEL
            else:
                return H8L_DEFAULT_MODEL

    @staticmethod
    def download_model(url: str, destination: str):
        if not url.endswith(".hef"):
            raise ValueError("Invalid model URL. Only .hef files are supported.")
        try:
            urllib.request.urlretrieve(url, destination)
            logger.debug(f"Downloaded model to {destination}")
        except Exception as e:
            raise RuntimeError(f"Failed to download model from {url}: {str(e)}") from e

    def check_and_prepare(self) -> str:
        if not os.path.exists(self.cache_dir):
            os.makedirs(self.cache_dir)
        model_name = self.extract_model_name(self.model_path, self.url)
        cached_model_path = os.path.join(self.cache_dir, model_name)
        if not self.model_path and not self.url:
            if os.path.exists(cached_model_path):
                logger.debug(f"Model found in cache: {cached_model_path}")
                return cached_model_path
            else:
                logger.debug(f"Downloading default model: {model_name}")
                if ARCH == "hailo8":
                    self.download_model(H8_DEFAULT_URL, cached_model_path)
                else:
                    self.download_model(H8L_DEFAULT_URL, cached_model_path)
        elif self.url:
            logger.debug(f"Downloading model from URL: {self.url}")

View on GitHub (pinned to ca18b8dc13)

Solutions

  1. Verify the URL opens in a browser/curl from the same network; fix or replace it if 404/403
  2. Check container DNS/internet access (docker run --network, DNS settings, proxy)
  3. Pre-download the .hef and configure model.path to the local file to skip downloading
  4. Retry after transient outages; once cached in /tmp/cache the download is skipped

Example fix

# curl test
curl -fL -o /tmp/m.hef "https://.../yolov8n.hef" && ls -l /tmp/m.hef
# then in config use local path:
# model:
#   path: /tmp/m.hef
Defensive patterns

Strategy: retry

Validate before calling

import urllib.request

def url_reachable(url: str) -> bool:
    try:
        req = urllib.request.Request(url, method='HEAD')
        return urllib.request.urlopen(req, timeout=10).status == 200
    except Exception:
        return False

Try / catch

for attempt in range(3):
    try:
        HailoDetector.download_model(url, dest)
        break
    except RuntimeError as e:
        if attempt == 2:
            logger.error('Model download failed: %s', e)
            raise

Prevention

When it happens

Trigger: Detector __init__ -> check_and_prepare -> download_model(url, dest) where urlretrieve throws: unreachable host, expired S3 link, 404 for a renamed HEF, or no internet in the container.

Common situations: Frigate container without network/DNS; Hailo model zoo link moved or removed; firewall blocking the CDN; transient outage during first startup before the model is cached.

Related errors


AI-assisted analysis of blakeblackshear/frigate@ca18b8dc13 (2026-08-27). Data as JSON: /api/errors/cda94b365e80e75b. Report an issue: GitHub.