HTTP Diagnostic

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

  1. Set backend server.keepAliveTimeout higher than reverse proxy timeout (e.g. 65 seconds if load balancer is 60s)
  2. Set server.headersTimeout higher than keepAliveTimeout (e.g. 66 seconds)
  3. Use an http.Agent with keepAlive: true and automated retry on ECONNRESET