{"record":{"id":"d62117bb381d83ab","repo":"reflex-dev/reflex","slug":"failed-to-download-the-template-he","errorCode":null,"errorMessage":"Failed to download the template: {he}","messagePattern":"Failed to download the template: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"reflex/utils/templates.py","lineNumber":143,"sourceCode":"    import httpx\n\n    # Create a temp directory for the zip download.\n    try:\n        temp_dir = tempfile.mkdtemp()\n    except OSError as ose:\n        logger.error(f\"Failed to create temp directory for download: {ose}\")\n        raise SystemExit(1) from None\n\n    # Use httpx GET with redirects to download the zip file.\n    zip_file_path: Path = Path(temp_dir) / \"template.zip\"\n    try:\n        # Note: following redirects can be risky. We only allow this for reflex built templates at the moment.\n        response = net.get(template_url, follow_redirects=True)\n        logger.debug(f\"Server responded download request: {response}\")\n        response.raise_for_status()\n    except httpx.HTTPError as he:\n        logger.error(f\"Failed to download the template: {he}\")\n        raise SystemExit(1) from None\n    try:\n        zip_file_path.write_bytes(response.content)\n        logger.debug(f\"Downloaded the zip to {zip_file_path}\")\n    except OSError as ose:\n        logger.error(f\"Unable to write the downloaded zip to disk {ose}\")\n        raise SystemExit(1) from None\n\n    # Create a temp directory for the zip extraction.\n    try:\n        unzip_dir = Path(tempfile.mkdtemp())\n    except OSError as ose:\n        logger.error(f\"Failed to create temp directory for extracting zip: {ose}\")\n        raise SystemExit(1) from None\n\n    try:\n        zipfile.ZipFile(zip_file_path).extractall(path=unzip_dir)\n        # The zip file downloaded from github looks like:\n        # repo-name-branch/**/*, so we need to remove the top level directory.","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/utils/templates.py#L125-L161","documentation":"Raised by `create_config_init_app_from_remote_template` when the httpx GET that downloads the template zip fails: either a network/transport error or a non-2xx HTTP status (raise_for_status). Any httpx.HTTPError (connect error, timeout, DNS failure, 404/500) triggers this, and the CLI exits with SystemExit(1).","triggerScenarios":"`reflex init` with a remote template URL while offline, behind a blocking proxy, with a bad URL (404), or when the template host returns 5xx; net.get(template_url, follow_redirects=True) raising httpx.HTTPError.","commonSituations":"Corporate proxies/firewalls blocking github codeload URLs; typo'd template URL; GitHub outage; flaky CI network; SSL inspection breaking TLS.","solutions":["Verify the template URL is correct and reachable (curl -I <url>).","Fix network access: proxy env vars (HTTPS_PROXY), VPN, or retry when connectivity is restored.","If the remote template is optional, fall back to the bundled default template (omit the URL)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import httpx\n\ndef template_url_ok(url: str) -> bool:\n    try:\n        r = httpx.head(url, follow_redirects=True, timeout=10)\n        return r.status_code == 200\n    except httpx.HTTPError:\n        return False","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        create_config_init_app_from_remote_template(...)\n        break\n    except SystemExit:\n        # network failure logged by reflex; back off and retry\n        time.sleep(2 ** attempt)\nelse:\n    # fall back to default template\n    initialize_default_app(...)","preventionTips":["Verify template URLs with curl before scripting init.","Configure proxy env vars (HTTPS_PROXY) in corporate networks.","Keep a local copy of heavily-used templates to avoid network dependency."],"tags":["reflex","templates","httpx","download","network","cli"],"backgroundTag":"template-download-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}