Skip to content
MtrXTools

UND_ERR_CONNECT_TIMEOUT

fetch couldn't open a connection in time

Seen in Node.js fetch (undici), Next.js builds

Node.js fetch (undici) could not complete the TCP or TLS connection within its connect timeout, 10 seconds by default.

Common causes

  • A firewall silently drops packets to the host or port.
  • The name resolves to an IPv6 or other address that is unreachable from this network.
  • A required proxy is not used: Node.js fetch ignores HTTP_PROXY and HTTPS_PROXY by default.
  • The event loop was blocked by CPU-heavy work, so the timer fired before the connection was handled.

How to fix it

  1. Check the "attempted address" in the error and test that host and port from the same machine.
  2. Check whether the name has AAAA records and IPv6 actually works here.
  3. Behind a proxy, configure undici ProxyAgent / EnvHttpProxyAgent, or NODE_USE_ENV_PROXY=1 on Node.js versions that support it.
  4. Move CPU-heavy work off the main thread.
Check the port from outside

Got a different message? Paste it into the error explainer.

Related errors

All 34 Command line & code errors