{"record":{"id":"03285e4a7ad87af2","repo":"harry0703/MoneyPrinterTurbo","slug":"failed-to-connect-to-elevenlabs-exc","errorCode":null,"errorMessage":"failed to connect to ElevenLabs: {exc}","messagePattern":"failed to connect to ElevenLabs: (.+?)","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":140,"sourceCode":"            if response.status_code == 401:\n                raise ElevenLabsAuthenticationError(\n                    \"ElevenLabs API key was rejected (401): \"\n                    f\"{_safe_response_error(response)}\"\n                )\n            if not response.ok:\n                raise ElevenLabsMusicError(\n                    \"ElevenLabs account check failed \"\n                    f\"({response.status_code}): \"\n                    f\"{_safe_response_error(response)}\"\n                )\n            try:\n                payload = response.json()\n            except ValueError as exc:\n                raise ElevenLabsMusicError(\n                    \"ElevenLabs returned an invalid subscription response\"\n                ) from exc\n    except requests.RequestException as exc:\n        raise ElevenLabsMusicError(\n            f\"failed to connect to ElevenLabs: {exc}\"\n        ) from exc\n    if not isinstance(payload, dict):\n        raise ElevenLabsMusicError(\n            \"ElevenLabs returned an unexpected subscription response\"\n        )\n    tier = str(payload.get(\"tier\") or \"\").strip().lower()\n    if not tier:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs subscription response does not include an account tier\"\n        )\n    if tier == \"free\":\n        raise ElevenLabsPaidPlanRequiredError(\n            \"ElevenLabs Music API requires a paid plan; \"\n            \"the current account is on the free tier\"\n        )\n    logger.info(f\"ElevenLabs account and plan check succeeded: tier={tier}\")\n    return payload","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L122-L158","documentation":"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.","triggerScenarios":"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.","commonSituations":"Offline dev machines; Docker containers without DNS configured; corporate MITM proxies whose CA cert is not in the container trust store; transient ISP outages.","solutions":["Verify outbound connectivity from the same environment: curl -v https://api.elevenlabs.io/v1/user/subscription.","For Docker: check DNS/resolv.conf and proxy env vars (HTTP_PROXY/HTTPS_PROXY) inside the container.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import socket\n\ndef elevenlabs_reachable(host='api.elevenlabs.io', timeout=5) -> bool:\n    try:\n        socket.create_connection((host, 443), timeout=timeout).close()\n        return True\n    except OSError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    test_connection()\nexcept ElevenLabsMusicError as e:\n    if 'failed to connect' in str(e):\n        schedule_retry_later()  # network issue, not account\n        show_user('Network unavailable; will retry')","preventionTips":["Check DNS/proxy env vars inside the deployment container, not just the host shell.","Add TLS-intercepting proxy CAs to the runtime trust store.","Treat connection errors as retryable background conditions; never fail the whole video job synchronously on them."],"tags":["elevenlabs","network","timeout","connectivity"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}