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
- Determine connect vs read timeout from the error type
- For connect timeouts:
nc -vz host portfrom the same machine - For read timeouts: measure the endpoint and fix the slow part
- Set explicit timeouts and retry idempotent requests with backoff
Detailed fix by platform
Python
- 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
- 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
- axios:
timeout: 30000produces "timeout of 30000ms exceeded" (ECONNABORTED) — that is a read+connect total, not per phase.
AWS
- 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/healthHow to diagnose
- Type — Connect timeout or read timeout?
- Reachability — Can this machine open a TCP connection to host:port?
- Server time — How long does the endpoint take (logs/APM)?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026