Error: connect ETIMEDOUT 10.0.4.12:5432

Node.js · updated 2026-11-03

Thrown when a TCP connect or a request gets no response within the timeout. Unlike ECONNREFUSED (something answered no), ETIMEDOUT means nothing answered at all, which usually points at the network path rather than the server process.

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

Quick fix

Check that the address and port in the message are the ones you meant, then test the path from the same machine: nc -vz host port. A hang there means a firewall, security group or routing problem; a quick refusal means the host is reachable and the problem is the service.

  1. Read the address and port in the error and compare them with your config for this environment.
  2. From the same host or container, run nc -vz <host> <port> (or curl -v for HTTP) to see whether anything answers.
  3. Check firewall rules, cloud security groups and database allowlists for the app server's outbound IP.
  4. If it only happens under load, look at connection pool size and the server's max connections.
  5. Set an explicit timeout and a retry with backoff for calls that cross the network.
typescript
// Fail fast with a clear message instead of hanging on the default
const res = await fetch(url, { signal: AbortSignal.timeout(5_000) }).catch((err) => {
  if (err.name === 'TimeoutError' || err.cause?.code === 'ETIMEDOUT') {
    throw new Error(`Timed out reaching ${new URL(url).host}: check network access from this server`);
  }
  throw err;
});

Why it happens

A firewall or security group drops the traffic

Cloud databases and internal services often only accept connections from allowlisted IPs or networks. Dropped packets produce a timeout, not a refusal, so the error looks like slowness.

The wrong host for this environment

A private IP or internal hostname copied from another environment, or a DNS name that resolves to an old address, points at a machine that never answers.

The server is overloaded or out of connections

A database at its connection limit or a server with a full accept queue can leave new connections waiting until they time out, especially during traffic spikes.

IPv6 tried first on a network without IPv6

When a hostname resolves to both IPv6 and IPv4, a connection attempt over a broken IPv6 route can hang. Newer Node versions try both (happy eyeballs), older ones may not.

Other fixes

  • For outbound HTTP, reuse connections with keep-alive so each request does not pay a new connect.
  • Log which host and port timed out at the call site: the stack trace alone often shows only internal frames.
  • In serverless or containers, confirm the function or task is attached to the network (VPC, subnet) that can reach the target.

Same error, other wording

  • Error: connect ETIMEDOUT 52.1.2.3:443
  • FetchError: request to https://api.example.com failed, reason: connect ETIMEDOUT
  • Error: read ETIMEDOUT

Let your coding agent catch the next one

Runheed records this error in production with the stack trace, the breadcrumbs before it and the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:

> Find the ETIMEDOUT errors in production, group them by host and port, tell me whether they cluster in time (load) or happen constantly (network access), and add explicit timeouts with retries where the calls cross the network.

Plans from $29/moSee what your agent readsSee the setupCancel any time from the billing portal

Related errors

References: Node.js errors: common system errors (ETIMEDOUT), Node.js net: socket.setTimeout and connect