ETIMEDOUT

Network - No response received within timeout period

Connection Timeout Errors

What It Means

A connection timeout occurs when a client waits too long for a server to respond. The server either didn't receive the request, is too slow to respond, or network issues are dropping packets.

# Browser error
ERR_CONNECTION_TIMED_OUT

# Node.js
Error: connect ETIMEDOUT 203.0.113.50:443

# curl
curl: (28) Connection timed out after 30001 milliseconds

# Python
socket.timeout: timed out

Types of Timeouts

Type Description
Connection timeout TCP handshake didn't complete in time
Read timeout Connected but response took too long
Socket timeout General network operation timeout
Request timeout Total time for complete request

Common Causes

  • Server unreachable: Server is down or IP is wrong
  • Firewall dropping packets: Silent drop instead of reject
  • Network congestion: Packets lost in transit
  • Server overloaded: Can't process requests fast enough
  • Routing issues: Packets can't reach destination
  • DNS pointing to wrong IP: Old IP that's no longer valid

Diagnosing the Issue

# Test basic connectivity
ping example.com
ping -c 4 203.0.113.50

# Trace the network path
traceroute example.com
mtr example.com

# Test TCP connection to specific port
nc -zv -w 5 example.com 443
telnet example.com 443

# Test with timeout
curl -v --connect-timeout 5 https://example.com

# Check where packets are dropping
sudo tcpdump -i any host example.com

# Test from different locations
# Use online tools like check-host.net

Timeout vs Connection Refused

  • Timeout: No response at all (packets dropped, server unreachable)
  • Connection Refused: Server actively rejects connection (fast RST response)

Timeout = silence. Connection refused = active rejection.

Firewall Rules

Firewalls often DROP packets silently instead of rejecting them, causing timeouts.

# Check if firewall is blocking outbound
sudo iptables -L OUTPUT -n

# Check cloud provider security groups
# AWS: Check inbound rules in Security Groups
# GCP: Check Firewall rules
# Azure: Check Network Security Groups

# Test if specific port is blocked
curl -v --connect-timeout 5 https://example.com:443
curl -v --connect-timeout 5 http://example.com:80

# If one works and the other doesn't,
# it's likely a port-specific firewall rule

Setting Appropriate Timeouts

Node.js / JavaScript

// fetch with timeout
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);

const response = await fetch(url, { signal: controller.signal });
clearTimeout(timeoutId);

// axios
axios.get(url, { timeout: 5000 });

// http module
http.request(options, callback).setTimeout(5000);

Python

# requests
requests.get(url, timeout=(3.05, 27))  # (connect, read)

# urllib
urllib.request.urlopen(url, timeout=10)

curl

# Connection timeout only
curl --connect-timeout 5 https://example.com

# Total timeout (including transfer)
curl --max-time 30 https://example.com

# Both
curl --connect-timeout 5 --max-time 30 https://example.com

Server-Side Configuration

# Nginx - increase timeouts for slow backends
proxy_connect_timeout 60s;
proxy_read_timeout 60s;
proxy_send_timeout 60s;

# Apache
Timeout 60
ProxyTimeout 60

# Node.js
server.timeout = 60000;  // 60 seconds
server.keepAliveTimeout = 5000;

Quick Fixes

  • Verify the IP is correct: dig example.com
  • Check firewall rules: Ensure port is open in security groups
  • Test from multiple locations: Determine if it's regional
  • Check server load: CPU, memory, network saturation
  • Increase timeout values: If server is legitimately slow
  • Add retries: Network issues can be transient

Catch timeouts before users do

UptimeSignal monitors response times and alerts you when endpoints become slow or unresponsive.

Start monitoring free →

Related Topics