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
- Check server logs: crash, memory, restarts?
- Retry with backoff: single resets are normal on a network and should be caught by the client.
- Align timeouts and keep-alive settings of client, server and intermediaries (client timeout shorter than server timeout).
- Do not reuse connections indefinitely; on error open a new one.
- Test another network, VPN/proxy/antivirus.
- Gather details with
curl -v,openssl s_clientortcpdump. - 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