EMZETT.
Login

ECONNRESET: connection reset by peer

In short: The other side ended the TCP connection abruptly while you were sending or expecting data.

In more detail: Messages: Error: read ECONNRESET (Node.js), Connection reset by peer (Linux), ERR_CONNECTION_RESET (Chrome). Unlike connection refused (nobody listens on the port) the connection was first established and then hard aborted (TCP RST).

In Depth

Possible causes

  • The server crashes or restarts.
  • A firewall, proxy or load balancer interrupts idle or long connections (idle timeout).
  • The server closes keep-alive connections that the client still wants to reuse.
  • Too large requests or violation of limits.
  • Unstable network (Wi-Fi, VPN, mobile) or security software blocking TLS traffic.
  • The server is overloaded and drops connections (backlog full).
  • TLS misconfiguration (wrong version/ciphers).

Solutions

  1. Check server logs: crash, memory, restarts?
  2. Retry with backoff: single resets are normal on a network and should be caught by the client.
  3. Align timeouts and keep-alive settings of client, server and intermediaries (client timeout shorter than server timeout).
  4. Do not reuse connections indefinitely; on error open a new one.
  5. Test another network, VPN/proxy/antivirus.
  6. Gather details with curl -v, openssl s_client or tcpdump.
  7. Check load and connection limits (for example ulimit -n).

Assessment

The pattern “error only sometimes” suggests timeouts or load peaks, “always” configuration or firewall. In Node.js: set req.on('error', ...) and Agent settings for keepAlive, do not leave errors unhandled, otherwise the process crashes.

See also: ERR_CONNECTION_REFUSED, ERR_CONNECTION_TIMED_OUT, HTTP keep-alive