Error: socket hang up
The server closed the connection before replying
Seen in Node.js http/https, axios, node-fetch, request, npm
Node.js sent a request but the connection closed before any response arrived (code ECONNRESET).
Common causes
- The server or a proxy closed a reused keep-alive connection just as a new request was sent on it.
- The server crashed, timed out or never called res.end() on its side.
- Sending plain HTTP to a TLS port, or HTTPS to a plain HTTP port.
- A proxy, WAF or load balancer dropped the request.
How to fix it
- Retry idempotent requests; set the client keep-alive timeout lower than the server keep-alive timeout.
- Check server and proxy logs for errors or timeouts at that moment.
- Check the URL scheme and port match.
- If you run the server, make sure every code path ends the response.
Got a different message? Paste it into the error explainer.
Related errors
- wrong version number · TLS spoken to something that isn't TLS
- curl: (7) Failed to connect · The connection was refused or unreachable
- curl: (52) Empty reply from server · The server closed the connection without replying
- UND_ERR_CONNECT_TIMEOUT · fetch couldn't open a connection in time
- unable to get local issuer certificate · The client can't find the certificate's issuer
- unable to verify the first certificate · The intermediate certificate is missing
- certificate has expired · The server certificate has expired
- self signed certificate in certificate chain · The chain ends in an untrusted root
- curl: (6) Could not resolve host · The hostname doesn't resolve
- curl: (28) Operation timed out · The request timed out
- curl: (51) SSL: no alternative certificate subject name matches target host name · The certificate doesn't match the hostname
- curl: (3) URL using bad/illegal format or missing URL · curl could not parse the URL