BerriAI/litellm · error · Timeout
BedrockException: Timeout Error
Error message
BedrockException: Timeout Error - {error_str} What it means
LiteLLM throws Timeout when Bedrock connectivity or inference exceeds time limits: 'Connect timeout on endpoint URL' (botocore failing to establish the TCP/TLS connection) or 'timed out' (request exceeded the client's timeout). The mapper normalizes both into litellm.Timeout so callers get one uniform type with the model attached. Unlike string-mapped branches, no response object is attached.
Solutions
- Raise the timeout: litellm.completion(..., timeout=300) or request_timeout, and set num_retries to ride out transient slowness
- Switch to streaming for long outputs so time-to-first-token governs instead of full-generation wall clock
- Verify network egress to bedrock-runtime.<region>.amazonaws.com:443 and corporate proxy configuration
- Check DNS / VPC endpoint resolution if connect timeouts (not read timeouts) recur
Example fix
# before resp = litellm.completion(model="bedrock/...", messages=msgs) # Connect timeout on endpoint URL # after resp = litellm.completion(model="bedrock/...", messages=msgs, timeout=300, num_retries=2, stream=True)
Defensive patterns
Strategy: retry
Type guard
import litellm
def is_timeout(e: BaseException) -> bool:
return isinstance(e, litellm.Timeout) Try / catch
try:
resp = litellm.completion(model='bedrock/...', messages=msgs, timeout=300)
except litellm.Timeout:
resp = litellm.completion(model='bedrock/...', messages=msgs, timeout=300, stream=True, num_retries=2) Prevention
- Use streaming for any generation that can exceed a few dozen seconds
- Set explicit timeout= sized to worst-case generation, not the 600s default
- Allow-list bedrock-runtime.<region>.amazonaws.com:443 on corporate proxies
- Distinguish connect vs read timeouts: connect failures point at network/DNS, not model speed
When it happens
Trigger: Slow non-streaming generations exceeding the configured litellm timeout (default 600s); network egress blocked to bedrock-runtime.<region>.amazonaws.com:443; DNS/proxy/VPC-endpoint misconfiguration producing botocore ConnectTimeoutError.
Common situations: Corporate proxies that must allow-list AWS endpoints; long max_tokens generations without streaming; VPC endpoints with broken private DNS; aggressive per-request timeouts set via timeout=/request_timeout.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timeout error occurred.
- Timeout error occurred.
- Timeout error occurred.
- Cisco AI Defense API call timed out after s
- Error fetching prompt version
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/9bfbff13dcbd0dd3.
Report an issue: GitHub.
Appendix: 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 77b7c6c40c)