Network, Connection & TLS Errors
ECONNRESET, ETIMEDOUT, TLS handshake failures — the fix for each.
18 documented errorsErrors in this category
TCP connection reset by remote host; usually mid-request server-side termination.
Connection refused; wrong port, service down, or firewall blocking.
Connection attempt exceeded system timeout; often DNS or routing issue.
No route to host; network configuration or DNS pointing to unreachable IP.
Node.js-specific ECONNRESET variant; connection closed before response completed.
TLS handshake failed; often clock skew, unsupported cipher, or MITM proxy.
Certificate chain includes self-signed cert; usually corporate proxy.
Server certificate expired; provider issue, contact them if it persists.
Server presented a self-signed certificate; usually staging endpoint or MITM.
Client and server can't agree on TLS version; upgrade client OpenSSL.
Related pillar guides
G2. Retry Logic Patterns That Actually Work
Network errors are the canonical retry-worthy failure. This pillar covers the classifier patterns and full retry-with-backoff logic.
G9. Exponential Backoff Explained with Working Code
The math and code for the retry timing that handles network failures without amplifying load.
Related blog posts
Frequently asked questions
Are network errors retryable?
Yes, almost always. ECONNRESET, ETIMEDOUT, socket hang up, EAI_AGAIN — all transient. Use exponential backoff (G9) and retry 3-5 times. The exception: ECONNREFUSED that persists across retries suggests wrong hostname or a hard outage; fail fast.
Why do I see ECONNRESET on the first request after a period of inactivity?
TCP connections in HTTP clients (Node's http.Agent, Python requests session) can be kept alive but silently killed by intermediate load balancers. First request on a dead connection fails with ECONNRESET. Fix: disable keep-alive for AI API calls, or use a client that retries the first ECONNRESET automatically.
How do I fix TLS certificate errors behind a corporate proxy?
Options: (1) install your corporate CA into Node's/Python's trust store, (2) use NODE_EXTRA_CA_CERTS environment variable pointing to the CA bundle, (3) route AI API traffic outside the proxy if policy allows. Never disable cert verification in production — it opens you to MITM attacks.
What's a reasonable timeout for AI API calls?
Connect timeout: 10 seconds. Read timeout: 60-120 seconds for non-streaming (larger for very long responses). For streaming, use inter-chunk timeouts (kill if no bytes for 30 seconds) rather than total timeout.
Why do I sometimes get partial JSON responses that end mid-object?
Almost always ECONNRESET during streaming or read. The provider generated the full response, but the connection dropped before you finished reading it. Retry the whole request — you can't resume from mid-response.
Are proxy errors different from provider errors?
Yes — proxy errors are your infrastructure, not the provider's. 407, tunnel failures, and header stripping issues are all on your side. Isolate by testing the same request from a different network (mobile hotspot, cloud shell). If it works elsewhere, it's your proxy.
Should I use IPv4 or IPv6 for AI API calls?
Most providers work equally well over both. Some corporate networks have inconsistent IPv6 support; prefer IPv4 (via node --dns-result-order=ipv4first or Python's family parameter) if you see intermittent connect failures on IPv6-preferring hosts.