BerriAI/litellm · error · Timeout
BedrockException: Timeout Error - {error_str}
Error message
BedrockException: Timeout Error - {error_str} What it means
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.
Source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:883
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif "AccessDeniedException" in error_str:
raise PermissionDeniedError(
message=f"BedrockException PermissionDeniedError - {error_str}",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif "throttlingException" in error_str or "ThrottlingException" in error_str:
raise RateLimitError(
message=f"BedrockException: Rate Limit Error - {error_str}",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif "Connect timeout on endpoint URL" in error_str or "timed out" in error_str:
raise Timeout(
message=f"BedrockException: Timeout Error - {error_str}",
model=model,
llm_provider="bedrock",
)
elif "Could not process image" in error_str:
raise litellm.InternalServerError(
message=f"BedrockException - {error_str}",
model=model,
llm_provider="bedrock",
)
elif hasattr(original_exception, "status_code"):
if original_exception.status_code == 500:
raise ServiceUnavailableError(
message=f"BedrockException - {original_exception.message}",
llm_provider="bedrock",
model=model,
response=httpx.Response(
status_code=500,View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before resp = litellm.completion(model="bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0", messages=msgs) # after resp = litellm.completion(model="bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0", messages=msgs, timeout=900, num_retries=2, stream=True)
Defensive patterns
Strategy: retry
Validate before calling
import socket
def bedrock_endpoint_reachable(region: str, timeout: float = 5.0) -> bool:
host = f"bedrock-runtime.{region}.amazonaws.com"
try:
socket.create_connection((host, 443), timeout=timeout).close()
return True
except OSError:
return False Type guard
import litellm
def is_bedrock_timeout(e: BaseException) -> bool:
return isinstance(e, litellm.Timeout) and getattr(e, "llm_provider", "") == "bedrock" Try / catch
try:
resp = litellm.completion(model="bedrock/...", messages=msgs, timeout=900, num_retries=2)
except litellm.Timeout:
raise RuntimeError("bedrock unreachable or too slow — check VPC egress/NAT and timeout budget") Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timeout error occurred.
- BedrockException: Context Window Error - {error_str}
- BedrockException Invalid Authentication - {error_str}
- BedrockException PermissionDeniedError - {error_str}
- BedrockException: Rate Limit Error - {error_str}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/9bfbff13dcbd0dd3.
Report an issue: GitHub.