Error explained
Error: read ECONNRESET
ECONNRESET means the other side abruptly closed the connection. Most often it is a reused keep-alive connection that the server had already closed.
3 min read8 sectionsUpdated
On this page
| Cause | Signs | Fix |
|---|---|---|
| Server closed an idle keep-alive connection | Intermittent, after quiet periods | Client idle timeout shorter than the server’s |
| Load balancer idle timeout | Long requests or idle sockets reset at a fixed time | Align timeouts; send keep-alives |
| Server crashed or restarted mid-request | Resets during deploys | Graceful shutdown; drain connections |
| Request too large / rejected | Reset right after sending a big body | Check body limits on proxy and server |
| TLS or protocol mismatch | Reset at connect | Check TLS versions and ports |
The keep-alive mismatch
Node's HTTP server closes idle keep-alive sockets after keepAliveTimeout (5 seconds by default). If a client or a load balancer in front keeps idle connections open longer, it may send a request on a socket the server is closing, and gets a reset. The rule: the server's keep-alive timeout must be longer than the idle timeout of whatever connects to it.
const server = app.listen(8080);
server.keepAliveTimeout = 65_000; // longer than a 60 s load balancer idle timeout
server.headersTimeout = 66_000; // must be above keepAliveTimeoutCatching it in production
Resets are usually intermittent, which makes them easy to ignore. Traces show which client call failed and to which host; group failures by target and time to see whether they line up with deploys or idle periods.
VitalRix error tracking groups exceptions recorded on OpenTelemetry spans into issues with counts, first and last seen, affected endpoints and versions, and marks an issue as regressed if it comes back after being resolved. Alert rules on error rate per service or endpoint route the problem to the right team before customers report it.
Is ECONNRESET a client or server problem?
Either. It only says the other side reset the connection. Check server logs at that moment; if they show nothing, look at proxies and idle timeouts in between.
Should I retry on ECONNRESET?
For idempotent requests, yes, once or twice with backoff. For payments and other non-idempotent requests, use idempotency keys.
Related reading
- Cloudflare error 522: connection timed out: Fix Cloudflare error 522 "Connection timed out": the origin did not complete the TCP connection in time. Overloaded servers, dropped packets and wrong DNS.
- ERR_CONNECTION_RESET: causes and how to fix it: Fix ERR_CONNECTION_RESET: crashed backends, firewalls and antivirus resetting traffic, MTU problems and keep-alive races, for both visitors and site owners.
- TypeError: Cannot read properties of undefined: What "Cannot read properties of undefined" means in JavaScript, the usual causes such as async data and missing fields, safe fixes with optional chaining.
- MySQL: Too many connections: Fix MySQL error 1040 Too many connections: check max_connections and current threads, find sleeping or leaked connections, size application pools.
- WordPress "Error establishing a database connection": fix: Fix WordPress Error establishing a database connection: check wp-config credentials, MySQL status, connection limits and damaged tables with safe commands.
- "Your connection is not private": how to fix it: Fix "Your connection is not private" (NET::ERR_CERT_*): expired or mismatched certificates, wrong device clocks, missing intermediates and Wi-Fi portals.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.