Error fix · Developer errors

Node.js ETIMEDOUT: connect ETIMEDOUT Causes and Fixes

Fix Node.js "connect ETIMEDOUT" and "read ETIMEDOUT" errors: tell firewall drops from slow servers, IPv6 fallbacks and proxies, then set sane timeouts.

Error messageError: connect ETIMEDOUT

By SiteDownCheck Editorial · Updated November 18, 2026 · 4 min read

ETIMEDOUT means the operating system gave up waiting. Your Node.js code tried to open a TCP connection (or read from one) and the peer never answered within the time limit. Unlike ECONNREFUSED, where the other side answers "no", a timeout means silence.

Error: connect ETIMEDOUT 203.0.113.10:443
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '203.0.113.10',
  port: 443
}

The syscall field matters. connect means the handshake never finished. read means the connection opened but the peer stopped sending. Those have different causes.

Decision order

  1. Reproduce it outside Node with curl or nc from the same machine.
  2. If it fails there too, the problem is the network path: firewall, routing, security group, or a dead server.
  3. If it works there but not in Node, suspect IPv6 versus IPv4, a proxy that curl honors but Node ignores, DNS returning several addresses, or a timeout in your own code.

Step 1: test from the same host

curl -v --connect-timeout 10 https://example.com/
nc -vz -w 5 203.0.113.10 443

If nc hangs and then times out, packets are being dropped. A firewall that rejects traffic usually yields "connection refused" quickly. A firewall that drops it yields a timeout. Cloud security groups, host firewalls (ufw, iptables, firewalld), corporate egress filtering and network ACLs all behave this way. Also test from a different network to see whether the target itself is the problem: the Port Checker probes a port from outside, and Down From Where shows whether a site is reachable from several regions.

Step 2: check what address Node picked

A hostname can resolve to both IPv6 and IPv4 addresses. If your host has an IPv6 address configured but no working IPv6 route, a connect attempt to the IPv6 address hangs.

node -e "require('dns').lookup('example.com',{all:true},(e,a)=>console.log(e||a))"
curl -4 -v --connect-timeout 10 https://example.com/
curl -6 -v --connect-timeout 10 https://example.com/

If -4 works and -6 hangs, fix IPv6 routing, remove the AAAA record if it is yours and wrong, or turn off IPv6 on the broken host. Recent Node versions enable "happy eyeballs" (autoSelectFamily) by default, which tries several addresses in turn and softens this problem. On older versions you can opt in with net.setDefaultAutoSelectFamily(true). See the net documentation for your version, and note that an AggregateError with several ETIMEDOUT entries is that fallback failing on every address. Check records with the DNS Checker.

Step 3: proxies

Node's built-in http and https do not read HTTP_PROXY or HTTPS_PROXY on their own in older versions, while curl does. If you are behind a corporate proxy, curl works and Node times out. Either configure an agent explicitly (for example with the https-proxy-agent package), or check whether your Node version documents proxy environment support for the client you use. Confirm your outbound address with What is my IP to see whether you leave via the proxy.

Step 4: the target is slow, not dead

If syscall is read, or you see ESOCKETTIMEDOUT from older libraries, the server accepted the connection but did not respond in time. Look at the server side: overloaded workers, a hung database, or an upstream stall. See nginx upstream timed out and Fix 504 Gateway Timeout.

Step 5: set explicit timeouts and retry sensibly

The kernel's default connect timeout can be a minute or more. Do not wait that long in a request path.

// fetch / undici: abort after 8 seconds
const res = await fetch(url, { signal: AbortSignal.timeout(8000) });

// raw http(s) request
const req = https.get(url, { timeout: 8000 }, handle);
req.on('timeout', () => req.destroy(new Error('request timeout')));
req.on('error', handleError);

Retry only idempotent requests, use exponential backoff with jitter, and cap attempts. Retrying a POST that may have been processed can duplicate work.

Step 6: container and cloud specifics

  • Docker: a container with no outbound route (wrong network, firewall rules, a VPN on the host) times out where the host does not. Test with docker run --rm curlimages/curl -v --connect-timeout 10 https://example.com.
  • Lambda or other serverless in a VPC: without a NAT gateway or VPC endpoint there is no internet path, and connects hang until the function times out.
  • Kubernetes: a NetworkPolicy or an egress restriction produces timeouts. Test with kubectl exec into the pod.
  • Database hosts: a managed database that allow-lists IP addresses silently drops everything else. Add your server's egress address.

Next steps

FAQ

What is the difference between ETIMEDOUT and ECONNREFUSED?

ECONNREFUSED is an immediate "nothing is listening here" answer. ETIMEDOUT means no answer arrived before the timer expired, usually because packets were dropped.

How long is the default timeout?

It comes from the operating system for connects and is often tens of seconds to minutes. Set your own, since Node's HTTP APIs have no short default.

Why does curl work but Node fails?

Common reasons are IPv6 selection, proxy environment variables that curl honors, or a different DNS result. Compare with curl -4, curl -6 and your proxy settings.

Can a firewall cause ETIMEDOUT?

Yes. A rule that drops packets, rather than rejecting them, makes connections hang until they time out.

Get notified when this fix updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.