Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

Error message
Connection timeout or reset on long-running or idle connections

Retry? 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

  1. Fix 1.

    Enable TCP keep-alive in your AWS SDK client.

    Snippet
    import boto3
    from botocore.config import Config
    
    config = Config(tcp_keepalive=True)
    client = boto3.client("bedrock-runtime", config=config)
  2. Fix 2.

    Lower the OS-level keep-alive interval to fire before the 350-second idle timeout (both settings are required).

    Snippet
    sysctl -w net.ipv4.tcp_keepalive_time=45

More Amazon Bedrock errors

All 22 Amazon Bedrock errors

FAQ

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.