Amazon Bedrock (Runtime API) error
Amazon Bedrock: "Connection timeout or reset on long-running or idle connections": what it means and how to fix it
Connection timeout or reset on long-running or idle connectionsRetry? Not statedLast verified 2 documented fixes1 source
What it means
API calls fail with connection resets or timeouts, especially for long-running requests such as streaming, extended thinking, or large inference responses, when traffic goes through NAT Gateways, interface VPC endpoints, or Network Load Balancers.
Causes
- NAT Gateways, interface VPC endpoints, and Network Load Balancers drop TCP connections idle longer than 350 seconds without notifying the client
How to fix it
- Fix 1.
Enable TCP keep-alive in your AWS SDK client.
Snippetimport boto3 from botocore.config import Config config = Config(tcp_keepalive=True) client = boto3.client("bedrock-runtime", config=config) - Fix 2.
Lower the OS-level keep-alive interval to fire before the 350-second idle timeout (both settings are required).
Snippetsysctl -w net.ipv4.tcp_keepalive_time=45
More Amazon Bedrock errors
All 22 Amazon Bedrock errorsFAQ
What does the Amazon Bedrock error "Connection timeout or reset on long-running or idle connections" mean?
API calls fail with connection resets or timeouts, especially for long-running requests such as streaming, extended thinking, or large inference responses, when traffic goes through NAT Gateways, interface VPC endpoints, or Network Load Balancers.
How do I fix Amazon Bedrock "Connection timeout or reset on long-running or idle connections"?
There are 2 documented fixes. Start with the first: Enable TCP keep-alive in your AWS SDK client.
Should I retry Amazon Bedrock "Connection timeout or reset on long-running or idle connections"?
Not stated. The official docs do not say whether this error is retryable.
Sources
Last verified against 1 source: Amazon Bedrock's official docs and official SDK repositories.
Newsletter
Know when the APIs change
One email per week. New model releases, API changes, what broke, and how developers are working around it.