Comfy-Org/ComfyUI · error · Exception

Failed to download (HTTP {resp.status}).

Error message

Failed to download (HTTP {resp.status}).

What it means

A download GET returned an HTTP status >= 400. Statuses in _RETRY_STATUS are retried with backoff up to max_retries; this exception is raised when the status is not retryable or retries are exhausted. The status code is embedded in the message.

Source

Thrown at comfy_api_nodes/util/download_helpers.py:135

                            body = await resp.json()
                        except (ContentTypeError, ValueError):
                            text = await resp.text()
                            body = text if len(text) <= 4096 else f"[text {len(text)} bytes]"
                        request_logger.log_request_response(
                            operation_id=op_id,
                            request_method="GET",
                            request_url=url,
                            response_status_code=resp.status,
                            response_headers=dict(resp.headers),
                            response_content=body,
                            error_message=f"HTTP {resp.status}",
                        )

                    if resp.status in _RETRY_STATUS and attempt <= max_retries:
                        await sleep_with_interrupt(delay, cls, None, None, None)
                        delay *= retry_backoff
                        continue
                    raise Exception(f"Failed to download (HTTP {resp.status}).")

                if is_path_sink:
                    p = Path(str(dest))
                    with contextlib.suppress(Exception):
                        p.parent.mkdir(parents=True, exist_ok=True)
                    fhandle = open(p, "wb")
                    sink = fhandle
                else:
                    sink = dest  # BytesIO or file-like

                written = 0
                while True:
                    try:
                        chunk = await asyncio.wait_for(resp.content.read(1024 * 1024), timeout=1.0)
                    except asyncio.TimeoutError:
                        chunk = b""
                    except asyncio.CancelledError:
                        raise ProcessingInterrupted("Task cancelled") from None

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Map the code: 404 -> the URL expired or is wrong, regenerate/re-fetch the asset URL; 401/403 -> re-authenticate; 429 -> slow down; 5xx -> provider issue, retry later.
  2. Reduce the delay between generation completing and the download step so signed URLs do not expire.
  3. Increase max_retries / backoff for transient 5xx providers.
  4. Check the logged response body (request_logger captures it) for a provider-side error message.
Defensive patterns

Strategy: retry

Try / catch

try:
    await download(url, ...)
except Exception as e:
    msg = str(e)
    if 'HTTP 404' in msg:
        url = await refresh_asset_url(asset_id)  # expired presigned URL
        return await download(url, ...)
    if 'HTTP 429' in msg:
        await asyncio.sleep(backoff)
        return await download(url, ...)
    raise

Prevention

When it happens

Trigger: 404 for an expired/pre-signed media URL (common when a generated asset URL expires before download), 401/403 for auth failures, 429/500/503 that persisted past the retry budget, in comfy_api_nodes/util/download_helpers.py:135.

Common situations: Long queues where the download starts after a signed URL's TTL elapsed; invalid or expired API credentials; provider outage returning 5xx for the whole retry window; rate limiting on burst downloads.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/7e503299a190280e. Report an issue: GitHub.