Fix "Error: read ECONNRESET" and "socket hang up" in Node.js & Axios
The remote server abruptly severed the TCP connection while Node.js was sending data or waiting for a response, often caused by load balancer keep-alive timeout race conditions.
Error: read ECONNRESET / socket hang up
Quick Fix Checklist
- Set backend server.keepAliveTimeout higher than reverse proxy timeout (e.g. 65 seconds if load balancer is 60s)
- Set server.headersTimeout higher than keepAliveTimeout (e.g. 66 seconds)
- Use an http.Agent with keepAlive: true and automated retry on ECONNRESET