ETIMEDOUT 🔌 API

API Request Timed Out (ETIMEDOUT / ReadTimeout / timeout of 30000ms exceeded)

The client gave up waiting — either for the connection to open or for the response to arrive.

Meaning

There are two different timeouts: a connect timeout (server/port unreachable — firewall, wrong host, server down) and a read timeout (connected, but the response is too slow). Knowing which one fired tells you whether to look at the network or at server performance.

Common causes

  • Firewall/security group dropping packets (connect timeout)
  • Wrong host or port, or the service is down
  • Slow endpoint, database query or upstream dependency (read timeout)
  • Client timeout set too low for a legitimately long operation
  • DNS resolution slow or failing
  • Server overloaded / rate limiting by delaying

⚡ Quick fix

  1. Determine connect vs read timeout from the error type
  2. For connect timeouts: nc -vz host port from the same machine
  3. For read timeouts: measure the endpoint and fix the slow part
  4. Set explicit timeouts and retry idempotent requests with backoff

Detailed fix by platform

Python

  1. Separate connect and read timeouts:
    python
    import requests
    try:
        r = requests.get(url, timeout=(3.05, 30))   # (connect, read)
    except requests.exceptions.ConnectTimeout:
        ...  # network/firewall/host problem
    except requests.exceptions.ReadTimeout:
        ...  # server too slow

Node.js

  1. fetch with AbortSignal timeout (Node 18+):
    javascript
    try {
      const res = await fetch(url, { signal: AbortSignal.timeout(10_000) });
    } catch (err) {
      if (err.name === 'TimeoutError') console.error('API took longer than 10s');
      else throw err;
    }

JavaScript

  1. axios: timeout: 30000 produces "timeout of 30000ms exceeded" (ECONNABORTED) — that is a read+connect total, not per phase.

AWS

  1. Lambda calling a VPC resource without a NAT gateway / security-group rule times out on connect.

Code examples

Test reachability and timing

bash
nc -vz api.example.com 443                 # connect works?
curl -o /dev/null -s -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://api.example.com/health

How to diagnose

  1. Type — Connect timeout or read timeout?
  2. Reachability — Can this machine open a TCP connection to host:port?
  3. Server time — How long does the endpoint take (logs/APM)?
  4. Timeouts — What are the client, proxy and server timeouts?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.