harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError

failed to connect to ElevenLabs: {exc}

Error message

failed to connect to ElevenLabs: {exc}

What it means

ElevenLabsMusicError raised by test_connection()'s except clause wrapping any requests.RequestException from the subscription GET — DNS failure, connection refused, TLS error, or read timeout beyond the (15s connect, 30s read) tuple. The original exception is chained, so the message includes requests' own detail (e.g. 'HTTPSConnectionPool... Max retries exceeded'). This is a connectivity/environment problem, not an account problem.

Source

Thrown at app/services/elevenlabs_music.py:140

            if response.status_code == 401:
                raise ElevenLabsAuthenticationError(
                    "ElevenLabs API key was rejected (401): "
                    f"{_safe_response_error(response)}"
                )
            if not response.ok:
                raise ElevenLabsMusicError(
                    "ElevenLabs account check failed "
                    f"({response.status_code}): "
                    f"{_safe_response_error(response)}"
                )
            try:
                payload = response.json()
            except ValueError as exc:
                raise ElevenLabsMusicError(
                    "ElevenLabs returned an invalid subscription response"
                ) from exc
    except requests.RequestException as exc:
        raise ElevenLabsMusicError(
            f"failed to connect to ElevenLabs: {exc}"
        ) from exc
    if not isinstance(payload, dict):
        raise ElevenLabsMusicError(
            "ElevenLabs returned an unexpected subscription response"
        )
    tier = str(payload.get("tier") or "").strip().lower()
    if not tier:
        raise ElevenLabsMusicError(
            "ElevenLabs subscription response does not include an account tier"
        )
    if tier == "free":
        raise ElevenLabsPaidPlanRequiredError(
            "ElevenLabs Music API requires a paid plan; "
            "the current account is on the free tier"
        )
    logger.info(f"ElevenLabs account and plan check succeeded: tier={tier}")
    return payload

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Verify outbound connectivity from the same environment: curl -v https://api.elevenlabs.io/v1/user/subscription.
  2. For Docker: check DNS/resolv.conf and proxy env vars (HTTP_PROXY/HTTPS_PROXY) inside the container.
  3. If behind a TLS-intercepting proxy, add its CA to the trust store; if just slow, retry — the read timeout is a fixed 30s for this cheap endpoint.
Defensive patterns

Strategy: retry

Validate before calling

import socket

def elevenlabs_reachable(host='api.elevenlabs.io', timeout=5) -> bool:
    try:
        socket.create_connection((host, 443), timeout=timeout).close()
        return True
    except OSError:
        return False

Try / catch

try:
    test_connection()
except ElevenLabsMusicError as e:
    if 'failed to connect' in str(e):
        schedule_retry_later()  # network issue, not account
        show_user('Network unavailable; will retry')

Prevention

When it happens

Trigger: No internet, DNS cannot resolve api.elevenlabs.io, firewall blocking outbound HTTPS, TLS-intercepting proxy with an untrusted CA, or the subscription endpoint taking longer than 30s to respond.

Common situations: Offline dev machines; Docker containers without DNS configured; corporate MITM proxies whose CA cert is not in the container trust store; transient ISP outages.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/03285e4a7ad87af2. Report an issue: GitHub.