adds code

Common networking gear Errors in Nodejs and Fixes

Published: 2026-03-07 · Updated: 2026-08-21

Quick answer: The five most common Node.js network errors are ECONNREFUSED, EADDRINUSE, ETIMEDOUT, ENOTFOUND, and ECONNRESET. Per the official Node.js errors documentation, they all surface as error objects carrying a code property — read that property first, because it tells you exactly which failure mode you are dealing with.

What does ECONNREFUSED mean and how do you fix it?

ECONNREFUSED means the connection attempt was refused because no process was listening on the target host and port. Fix: confirm the server process is actually running, then verify the port number and hostname your client code uses match what the server binds to.

How do you fix EADDRINUSE?

EADDRINUSE appears when your server tries to bind a port another process already holds. Two fixes: stop the other process, or bind your server to a different port. This is one of the most common errors when restarting a Node.js app whose old instance has not fully exited yet.

Why do connections time out with ETIMEDOUT?

ETIMEDOUT means the remote endpoint never responded within the timeout window. Typical causes: a firewall silently dropping packets, a wrong IP address, or an overloaded peer. Check basic reachability first (ping or curl the target), then review any explicit timeout settings in your client code.

What causes ENOTFOUND in Node.js?

ENOTFOUND is a DNS resolution failure — the hostname could not be resolved to an IP address. Node.js performs DNS lookups through its dns module. Fix: check the hostname spelling, then test whether your resolver can resolve it at all.

Which error code means what? Quick reference table

CodeMeaningFirst thing to check
ECONNREFUSEDNothing listening at host:portIs the server process running?
EADDRINUSEPort already bound by another socketStop the other process or change port
ETIMEDOUTRemote host never respondedFirewall, routing, or peer outage
ENOTFOUNDDNS lookup failedHostname spelling and DNS resolver
ECONNRESETConnection closed abruptly by the peerPeer crash, restart, or load issue

How should production apps handle these errors?

The net module documentation shows that sockets emit 'error' events rather than throwing in callbacks — always attach an error handler so an unhandled event does not crash the process. For TLS problems such as certificate failures, the tls module documentation covers how secure connections are validated. Retry only transient codes (ETIMEDOUT, ECONNRESET) with backoff; treat configuration errors like EADDRINUSE as bugs to fix, not to retry.

Recommended Products

Here are our top picks to get you started:

Product for networking gear

Recommended based on your needs

Price: $29.99

Search on Amazon

As an Amazon Associate I earn from qualifying purchases.

Frequently Asked Questions

What is the difference between ECONNREFUSED and ETIMEDOUT?

ECONNREFUSED gets an active answer — the remote machine explicitly refuses because nothing listens on that port. ETIMEDOUT gets no answer at all — packets go unanswered until the timeout expires.

Does EADDRINUSE mean my code is broken?

Not necessarily. It usually means another instance of your own app is still holding the port. Find and stop it, or configure a different port.

Where is the full list of Node.js error codes?

In the official errors documentation, which documents system errors and their code properties.

Sources

Node.js Development

Published: 2026-03-07

Previous Post Next Post