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
- Check the "attempted address" in the error and test that host and port from the same machine.
- Check whether the name has AAAA records and IPv6 actually works here.
- Behind a proxy, configure undici ProxyAgent / EnvHttpProxyAgent, or NODE_USE_ENV_PROXY=1 on Node.js versions that support it.
- Move CPU-heavy work off the main thread.
Got a different message? Paste it into the error explainer.
Related errors
- wrong version number · TLS spoken to something that isn't TLS
- curl: (7) Failed to connect · The connection was refused or unreachable
- curl: (52) Empty reply from server · The server closed the connection without replying
- Error: socket hang up · The server closed the connection before replying
- unable to get local issuer certificate · The client can't find the certificate's issuer
- unable to verify the first certificate · The intermediate certificate is missing
- certificate has expired · The server certificate has expired
- self signed certificate in certificate chain · The chain ends in an untrusted root
- curl: (6) Could not resolve host · The hostname doesn't resolve
- curl: (28) Operation timed out · The request timed out
- curl: (51) SSL: no alternative certificate subject name matches target host name · The certificate doesn't match the hostname
- curl: (3) URL using bad/illegal format or missing URL · curl could not parse the URL