ETIMEDOUT — Connection Timed Out Debugging
Diagnose ETIMEDOUT (Connection Timed Out) errors in network programming. Learn the difference between connection timeout and read timeout, and how to troubleshoot across systems.
Detailed Explanation
ETIMEDOUT (errno 110)
ETIMEDOUT indicates that a connection attempt or I/O operation did not complete within the allowed time. Unlike ECONNREFUSED (which gets an immediate rejection), a timeout means no response was received at all.
Why Timeouts Happen
- Firewall silently dropping packets — The most common cause. The target host's firewall drops incoming packets without sending a RST or ICMP response
- DNS resolution failure — The hostname cannot be resolved, and the DNS query itself times out
- Network routing issues — Packets cannot reach the destination due to misconfigured routes
- Server overloaded — The server's accept queue is full and it cannot process new connections
- MTU/fragmentation issues — Large packets being dropped by intermediate network devices
Connection Timeout vs Read Timeout
- Connection timeout — Time allowed for the TCP three-way handshake to complete
- Read timeout (also called socket timeout) — Time allowed to receive data after the connection is established
// Node.js: separate timeouts
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
fetch('https://api.example.com/data', {
signal: controller.signal
}).finally(() => clearTimeout(timeout));
Troubleshooting Steps
- Verify DNS:
nslookup hostnameordig hostname - Check reachability:
ping hostname(ICMP may be blocked) - Test TCP connection:
nc -zv hostname port -w 5 - Trace the route:
traceroute hostnameormtr hostname - Check from different network: VPN, different server, or mobile hotspot
- Review firewall rules: Both local and remote
Setting Appropriate Timeouts
- Health checks: 2-5 seconds
- Internal API calls: 5-10 seconds
- External API calls: 10-30 seconds
- Batch processing: 60-300 seconds
Use Case
Timeout errors are the most common source of cascading failures in distributed systems. Understanding how to set appropriate timeouts, implement circuit breakers, and differentiate between connection and read timeouts is essential for building resilient microservice architectures. A missing or too-high timeout can bring down an entire system when one upstream dependency becomes slow.