invoke-ai/InvokeAI · error · ExternalProviderRequestError

{label} network error: {exc}

Error message

{label} network error: {exc}

What it means

_request_with_retry wraps every DashScope HTTP call (sync POST, async submit POST, task poll GET). If requests raises a RequestException (connection refused, DNS failure, timeout, SSL error) on the final allowed attempt (attempt >= _MAX_RETRIES, i.e. 3 total tries), it raises ExternalProviderRequestError labeled '<label> network error' with the underlying exception.

Source

Thrown at invokeai/app/services/external_generation/providers/alibabacloud.py:370

        json: dict | None = None,
    ) -> requests.Response:
        """Issue a request with limited retries on transient failures (429/5xx, network errors).

        Honors `Retry-After` for 429 responses when present. Non-retryable errors
        (4xx other than 429, parse failures) are returned to the caller, which is
        responsible for raising a meaningful ExternalProviderRequestError.
        """
        last_exc: Exception | None = None
        for attempt in range(_MAX_RETRIES + 1):
            try:
                if method == "POST":
                    response = requests.post(url, headers=headers, json=json, timeout=timeout)
                else:
                    response = requests.get(url, headers=headers, timeout=timeout)
            except requests.RequestException as exc:
                last_exc = exc
                if attempt >= _MAX_RETRIES:
                    raise ExternalProviderRequestError(f"{label} network error: {exc}") from exc
                delay = _RETRY_BACKOFF_BASE * (2**attempt)
                self._logger.warning(
                    "%s network error on attempt %d/%d: %s — retrying in %.1fs",
                    label,
                    attempt + 1,
                    _MAX_RETRIES + 1,
                    exc,
                    delay,
                )
                time.sleep(delay)
                continue

            if response.status_code in _RETRY_STATUS_CODES and attempt < _MAX_RETRIES:
                delay = self._retry_delay(response, attempt)
                self._logger.warning(
                    "%s got status %d on attempt %d/%d — retrying in %.1fs",
                    label,
                    response.status_code,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Read the wrapped exception (e.g. ConnectionError vs Timeout vs SSLError) to identify the network layer at fault
  2. Verify outbound HTTPS access to your external_alibabacloud_base_url from the app host (curl the endpoint)
  3. Check DNS configuration and proxy env vars (HTTP_PROXY/HTTPS_PROXY/NO_PROXY)
  4. If timeouts dominate, increase the timeout passed to _post_with_retry or reduce generation size/complexity
  5. Implement higher-level retry/backoff in the calling service for sustained outages

Example fix

// before
response = self._post_with_retry(endpoint, headers=headers, json=payload, timeout=120, label="DashScope sync")
// after
try:
    response = self._post_with_retry(endpoint, headers=headers, json=payload, timeout=120, label="DashScope sync")
except ExternalProviderRequestError as e:
    logger.warning("DashScope unreachable, aborting generation: %s", e)
    raise
Defensive patterns

Strategy: retry

Validate before calling

import requests
def check_connectivity(base_url: str) -> bool:
    try:
        requests.get(base_url, timeout=10)
        return True
    except requests.RequestException:
        return False

Try / catch

try:
    result = provider.generate(request)
except ExternalProviderRequestError as e:
    if "network error" in str(e):
        log.warning("DashScope unreachable after 3 attempts: %s", e)
        # schedule the job for retry rather than failing permanently
        requeue(request)
    else:
        raise

Prevention

When it happens

Trigger: Connection reset/refused to dashscope-intl.aliyuncs.com; DNS resolution failure; request timeout (120s sync, 60s async submit, 30s poll); TLS handshake failure; repeated transient network errors across all 3 attempts with exponential backoff (2s, 4s).

Common situations: Egress firewall blocking the DashScope endpoint from the container; DNS misconfiguration in Kubernetes; DashScope regional outage; long generations exceeding the 120s request timeout; proxy environments with unstable connections.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/d7b2a5dbe604b23a. Report an issue: GitHub.