{"record":{"id":"9bfbff13dcbd0dd3","repo":"BerriAI/litellm","slug":"bedrockexception-timeout-error-error-str","errorCode":null,"errorMessage":"BedrockException: Timeout Error - {error_str}","messagePattern":"BedrockException: Timeout Error - (.+?)","errorType":"exception","errorClass":"Timeout","httpStatus":408,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":883,"sourceCode":"            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"AccessDeniedException\" in error_str:\n        raise PermissionDeniedError(\n            message=f\"BedrockException PermissionDeniedError - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"throttlingException\" in error_str or \"ThrottlingException\" in error_str:\n        raise RateLimitError(\n            message=f\"BedrockException: Rate Limit Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Connect timeout on endpoint URL\" in error_str or \"timed out\" in error_str:\n        raise Timeout(\n            message=f\"BedrockException: Timeout Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n        )\n    elif \"Could not process image\" in error_str:\n        raise litellm.InternalServerError(\n            message=f\"BedrockException - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n        )\n    elif hasattr(original_exception, \"status_code\"):\n        if original_exception.status_code == 500:\n            raise ServiceUnavailableError(\n                message=f\"BedrockException - {original_exception.message}\",\n                llm_provider=\"bedrock\",\n                model=model,\n                response=httpx.Response(\n                    status_code=500,","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L865-L901","documentation":"Bedrock-specific: Timeout raised when the AWS error text contains 'Connect timeout on endpoint URL' or 'timed out' — the HTTP connection to the Bedrock runtime endpoint could not be established or the call exceeded the client timeout before any response.","triggerScenarios":"botocore failing to reach bedrock-runtime.<region>.amazonaws.com (network egress blocked, DNS failure, VPC without NAT), slow corporate proxies, or the request exceeding litellm's configured timeout (default 600s) on very long generations.","commonSituations":"Containers/lambda in a VPC without internet route or a bedrock VPC endpoint, firewall rules blocking port 443 to AWS, DNS misconfiguration, cross-region latency, or oversized prompts making the model exceed the client timeout.","solutions":["If connect-timeout: verify network egress to bedrock-runtime.<region>.amazonaws.com:443 (curl -I) and add a VPC endpoint or NAT gateway in private subnets.","If generation-timeout: raise litellm.completion(..., timeout=...) or set litellm.request_timeout.","Enable streaming so long generations deliver tokens incrementally.","Retry with num_retries for transient network blips."],"exampleFix":"# before\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", messages=msgs)\n\n# after\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", messages=msgs, timeout=900, num_retries=2, stream=True)","handlingStrategy":"retry","validationCode":"import socket\n\ndef bedrock_endpoint_reachable(region: str, timeout: float = 5.0) -> bool:\n    host = f\"bedrock-runtime.{region}.amazonaws.com\"\n    try:\n        socket.create_connection((host, 443), timeout=timeout).close()\n        return True\n    except OSError:\n        return False","typeGuard":"import litellm\n\ndef is_bedrock_timeout(e: BaseException) -> bool:\n    return isinstance(e, litellm.Timeout) and getattr(e, \"llm_provider\", \"\") == \"bedrock\"","tryCatchPattern":"try:\n    resp = litellm.completion(model=\"bedrock/...\", messages=msgs, timeout=900, num_retries=2)\nexcept litellm.Timeout:\n    raise RuntimeError(\"bedrock unreachable or too slow — check VPC egress/NAT and timeout budget\")","preventionTips":["In private VPCs, add a bedrock-runtime VPC endpoint or NAT gateway; test 443 egress before deploying.","Size litellm timeout to worst-case generation time; stream long outputs.","Distinguish 'Connect timeout' (network) from generation timeouts in alerting."],"tags":["bedrock","timeout","network","aws","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}