Error: socket hang up / read ECONNRESET
The other side closed the TCP connection abruptly while your client was still using it.
Meaning
The connection was established, then reset. Typical culprits are keep-alive connections reused after the server (or a load balancer) already closed them, servers crashing mid-response, and proxies/firewalls killing long or idle connections.
Common causes
- Reusing a keep-alive socket the server already closed (server keep-alive timeout < client’s)
- Upstream crashed or restarted while handling the request
- Load balancer/NAT idle timeout dropping the connection
- TLS/protocol mismatch (HTTP to an HTTPS port)
- Request body too large → server closes early
⚡ Quick fix
- Retry idempotent requests once on ECONNRESET
- Make server keep-alive timeout longer than the load balancer’s idle timeout
- Check server logs for crashes at the same time
- Verify protocol/port (https on 443)
Detailed fix by platform
Node.js
- Server keep-alive longer than the ALB idle timeout (60s):javascript
const server = app.listen(3000); server.keepAliveTimeout = 65_000; server.headersTimeout = 66_000; // must be greater than keepAliveTimeout
Python
- requests: mount an HTTPAdapter with
Retry(total=3, allowed_methods=None, backoff_factor=0.5)to retry connection resets.
How to diagnose
- When — First request or reused connection?
- Server — Crash/restart logs at that time?
- Timeouts — Keep-alive vs LB idle timeout
- Protocol — Right scheme and port?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026