{"record":{"id":"cda94b365e80e75b","repo":"blakeblackshear/frigate","slug":"failed-to-download-model-from-url-str-e","errorCode":null,"errorMessage":"Failed to download model from {url}: {str(e)}","messagePattern":"Failed to download model from (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"frigate/detectors/plugins/hailo8l.py","lineNumber":306,"sourceCode":"        if path and path.endswith(\".hef\"):\n            return os.path.basename(path)\n        elif url and url.endswith(\".hef\"):\n            return os.path.basename(url)\n        else:\n            if ARCH == \"hailo8\":\n                return H8_DEFAULT_MODEL\n            else:\n                return H8L_DEFAULT_MODEL\n\n    @staticmethod\n    def download_model(url: str, destination: str):\n        if not url.endswith(\".hef\"):\n            raise ValueError(\"Invalid model URL. Only .hef files are supported.\")\n        try:\n            urllib.request.urlretrieve(url, destination)\n            logger.debug(f\"Downloaded model to {destination}\")\n        except Exception as e:\n            raise RuntimeError(f\"Failed to download model from {url}: {str(e)}\") from e\n\n    def check_and_prepare(self) -> str:\n        if not os.path.exists(self.cache_dir):\n            os.makedirs(self.cache_dir)\n        model_name = self.extract_model_name(self.model_path, self.url)\n        cached_model_path = os.path.join(self.cache_dir, model_name)\n        if not self.model_path and not self.url:\n            if os.path.exists(cached_model_path):\n                logger.debug(f\"Model found in cache: {cached_model_path}\")\n                return cached_model_path\n            else:\n                logger.debug(f\"Downloading default model: {model_name}\")\n                if ARCH == \"hailo8\":\n                    self.download_model(H8_DEFAULT_URL, cached_model_path)\n                else:\n                    self.download_model(H8L_DEFAULT_URL, cached_model_path)\n        elif self.url:\n            logger.debug(f\"Downloading model from URL: {self.url}\")","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/blakeblackshear/frigate/blob/ca18b8dc131ccb3e086f13a780853b775ef13426/frigate/detectors/plugins/hailo8l.py#L288-L324","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the URL opens in a browser/curl from the same network; fix or replace it if 404/403","Check container DNS/internet access (docker run --network, DNS settings, proxy)","Pre-download the .hef and configure model.path to the local file to skip downloading","Retry after transient outages; once cached in /tmp/cache the download is skipped"],"exampleFix":"# curl test\ncurl -fL -o /tmp/m.hef \"https://.../yolov8n.hef\" && ls -l /tmp/m.hef\n# then in config use local path:\n# model:\n#   path: /tmp/m.hef","handlingStrategy":"retry","validationCode":"import urllib.request\n\ndef url_reachable(url: str) -> bool:\n    try:\n        req = urllib.request.Request(url, method='HEAD')\n        return urllib.request.urlopen(req, timeout=10).status == 200\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        HailoDetector.download_model(url, dest)\n        break\n    except RuntimeError as e:\n        if attempt == 2:\n            logger.error('Model download failed: %s', e)\n            raise","preventionTips":["Pre-download the .hef into a mounted volume and use model.path","Validate the URL with a HEAD request at startup","Ensure container DNS/egress is allowed to the model CDN"],"tags":["hailo","download","network","model-url"],"backgroundTag":"model-download-failed","analyzedSha":"ca18b8dc131ccb3e086f13a780853b775ef13426","analyzedAt":"2026-08-27T11:28:05.618Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}