ECONNRESET and ERR_CONNECTION_RESET: connection reset, fixes
What you see
Error: read ECONNRESETError: socket hang upcode: 'ECONNRESET'AxiosError: read ECONNRESET
More error strings (13)
SocketError: other side closedUND_ERR_SOCKETrequests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))ConnectionResetError: [Errno 104] Connection reset by peerConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote hostWSAECONNRESETnet::ERR_CONNECTION_RESETError: net::ERR_CONNECTION_RESET atpage.goto: net::ERR_CONNECTION_RESET atpage.goto: NS_ERROR_NET_RESETRecv failure: Connection reset by peerCURL ERROR: Recv failure: Connection reset by peer
What it means
The other side cut the line in the middle of a request. Not politely: it sent a TCP reset (RST, a “this connection is dead” signal) and dropped the line. You get no status code, no error page, nothing to read. The “other side” is whatever you were connected to: the site, a firewall in front of it, or your proxy.
Why it happens
A reset is like someone slamming the phone down mid-sentence. You know the call ended. You don’t know why. These are the usual causes, most common first:
- A stale keep-alive socket. Keep-alive means reusing one open connection for many requests. If the server closes it at the same moment your client reuses it, Node’s docs say the request “may encounter an ECONNRESET error”. Since Node v19, the global agent keeps connections alive by default.
- The site doesn’t like your TLS handshake. TLS is the encryption setup at the start of every
https://connection, and each client does it a little differently. In claude-code issue #37300 (Mar 2026), a user reported that Cloudflare rejected Node’s standard handshake withECONNRESET, while Chrome on the same network connected fine. - The site doesn’t like your browser. In Puppeteer issue #1477,
page.gotofailed withnet::ERR_CONNECTION_RESET. One commenter said the server was rejecting headless Chrome. Setting a normal user agent fixed it, and another said it made the on-and-off resets stop. - You opened too many connections too fast. Servers can cut you off before you ever see a 429. HAProxy’s docs show a rule that drops new connections from one IP above a chosen rate:
reject“closes the connection without sending any response”. - Your proxy dropped the line. Through a proxy, your connection goes to the proxy, not the site. If the proxy or its exit IP goes away mid-request, the proxy is the one that hangs up.
- The server crashed or restarted. Node’s docs blame “a timeout or reboot” on the remote side, and Microsoft’s list also names a stopped app or a disabled network interface.
Not every block ends in a reset. HAProxy’s silent-drop makes the connection “suddenly disappear” and tries not to send a FIN or RST at all. Your client still thinks it is connected, so you see a timeout, not a reset.
Resets turn up where you’d expect a block page. A block page needs an HTTP answer, like a 403 or a 429. A reset means the cut happened lower down, before any HTTP answer was sent.
The keep-alive race. A Node.js server closes an idle connection after 5 seconds by default (server.keepAliveTimeout). Servers may announce it as Keep-Alive: timeout=5. Send your next request just as that clock runs out, and your request lands on a closing socket.
The TLS check reads your first message, the ClientHello: TLS versions, cipher suites, extensions and their order. These differ per client, so a site can tell Python requests from Chrome even with identical headers. curl_cffi also copies HTTP/2 settings.
Cloudflare documents the check. JA3 and JA4 fingerprints “identify TLS clients based on how they initiate connections”, and site owners can act on them in WAF custom rules, Transform Rules and Workers.
Proxy drops have a documented cause as well. Apify’s residential proxy docs say a session “can be destroyed at any time” when the home device behind it is turned off or disconnected.
Fix it
- Check when it fails. First request every time? Likely a block (causes 2 to 4). Random ones, after a few idle seconds? Likely keep-alive (cause 1). Only under load? Likely rate limits (cause 4).
- Retry once on a fresh connection. For a GET, that is safe, and Node’s docs show the pattern: retry when
req.reusedSocketis true and the code isECONNRESET. In Python, use urllib3’sRetrywithread=set (code in the Dev details section). - Test the URL by itself. Run
curl -v <url>and open it in a normal browser on the same network. Browser works, your script resets? The site is judging your client, not your IP. - Look like a browser at the TLS layer. curl_cffi copies a real browser’s TLS and HTTP/2 fingerprints:
curl_cffi.get(url, impersonate="chrome"). Its README says: if a site blocks you “for no obvious reason”, give it a try. - In a headless browser, send a real user agent. That was the fix in Puppeteer issue #1477:
page.setUserAgent('Mozilla/5.0 …'). - Slow down. Fewer requests in parallel, a pause in between. If resets start only under load, this is your fix.
- Through a proxy, test without it. Same URL, direct, with curl. Works direct but not proxied? Start a new proxy session or IP, then retry.
Don’t retry a POST (a form or a checkout) blindly. urllib3 warns that read errors happen after the request has been sent, “so the request may have side-effects”.
Why one retry often works: with keep-alive, the first failure is a race and not a ban. Your client picked a connection the server had already started to close. A second try gets a fresh one.
Why it doesn’t fix a block: a site that resets you for your fingerprint resets you every time. When a retry fails the same way, stop and change the client (steps 4 and 5).
Turning keep-alive off (keepAlive: false) is a test, not a fix: every request then opens a new TCP connection. If the resets stop, you found cause 1. Turn it back on and add the reused-socket retry or agentKeepAliveTimeoutBuffer, so your side hangs up first.
On step 6, our advice: HAProxy’s example rule counts fresh connections from your IP, so keep-alive helps you stay under limits like it.
Paste this into your AI
My scraper fails with a connection reset:
"<paste the full error, including everything after 'Caused by' or 'cause'>"
Tell me in plain words who cut the connection: the website, my proxy, or a stale reused connection.
Then list the likely causes in order, most likely first: keep-alive reuse,
TLS fingerprint blocking, rate limiting, a dropped proxy exit.
For each cause, give one quick test and one fix.
Show a curl -v command that tests the same URL directly and through my proxy.
My setup: <language + library or browser tool, version>,
<direct, or proxy: provider + residential/datacenter, rotating/sticky>,
requests in parallel: <number>, keep-alive: <on/off/default>,
does the URL open in a normal browser on the same network? <yes/no>,
does it fail on the first request or after a while? <first / after N requests / random>.Dev details
What each tool prints
| tool | error | where it comes from |
|---|---|---|
Node.js http / axios |
Error: read ECONNRESET (code: 'ECONNRESET', syscall: 'read', errno: -104) |
Node system error |
Node.js http |
Error: socket hang up (code ECONNRESET) |
closed before any response |
Node.js fetch (undici) |
SocketError: other side closed (code UND_ERR_SOCKET) |
undici |
| Python requests | ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) |
urllib3 ProtocolError |
| Python on Windows | ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host |
Winsock WSAECONNRESET |
| Chrome, Puppeteer, Playwright | net::ERR_CONNECTION_RESET |
Chromium CONNECTION_RESET (-101) |
| Playwright with Firefox | page.goto: NS_ERROR_NET_RESET |
Firefox |
| curl, PHP cURL | Recv failure: Connection reset by peer |
curl |
urllib3 wraps any OSError during a request as ProtocolError("Connection aborted.", e). So the useful part is the one inside: ConnectionResetError is a reset, while RemoteDisconnected('Remote end closed connection without response') is a plain close.
Python’s ConnectionResetError is a subclass of ConnectionError and maps to errno ECONNRESET. On Windows this same code is Winsock error 10054.
Chromium’s three ways to lose a connection
// A connection was closed (corresponding to a TCP FIN).
NET_ERROR(CONNECTION_CLOSED, -100)
// A connection was reset (corresponding to a TCP RST).
NET_ERROR(CONNECTION_RESET, -101)
// The server closed the connection without sending any data.
NET_ERROR(EMPTY_RESPONSE, -324)
ERR_CONNECTION_CLOSED is a polite hang-up. ERR_CONNECTION_RESET is the slammed phone. ERR_EMPTY_RESPONSE means the server closed before saying anything.
Node.js: retry a reset on a reused socket
From the official Node.js HTTP docs:
import http from 'node:http';
const agent = new http.Agent({ keepAlive: true });
function retriableRequest() {
const req = http
.get('http://localhost:3000', { agent }, (res) => {
// ...
})
.on('error', (err) => {
if (req.reusedSocket && err.code === 'ECONNRESET') {
retriableRequest();
}
});
}
Since Node v24.7.0 and v22.20.0, http.Agent takes agentKeepAliveTimeoutBuffer (default 1000 ms). It subtracts that from the server’s Keep-Alive: timeout=… hint, so your agent closes the socket a bit before the server does.
Python requests: retry resets, not only connect errors
HTTPAdapter(max_retries=3) doesn’t cover this. The requests docs say an integer applies only to failed DNS lookups, socket connections and connection timeouts, “never to requests where data has made it to the server”. A reset after the request went out is a read error. Pass a urllib3 Retry:
import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry
retry = Retry(total=3, connect=3, read=2, backoff_factor=0.5)
s = requests.Session()
s.mount("https://", HTTPAdapter(max_retries=retry))
r = s.get("https://example.com/page", timeout=(3.05, 27))
Retry retries only DELETE, GET, HEAD, OPTIONS, PUT and TRACE by default (allowed_methods), so POSTs are left alone. backoff_factor sets the wait between tries: at 0.1, urllib3 sleeps 0.0 s, 0.2 s, 0.4 s, 0.8 s and never past backoff_max (120 s).
TLS fingerprint: swap the client
import curl_cffi
r = curl_cffi.get("https://example.com/page", impersonate="chrome")
impersonate="chrome" picks the latest Chrome curl_cffi knows and needs no version number.
Rate limits that cut you off
A server-level rule from HAProxy’s docs:
tcp-request connection reject if { src_conn_rate gt 10 }
reject “closes the connection without sending any response”. HAProxy notes that connection-level rejects go unlogged, because they target floods like DDoS attacks.
Edge cases
- The reset can be yours. Bright Data logs a client that hangs up on its proxy first as
client_10140(“Client disconnect”), usually from a client timeout, a cancelled request or a local network problem. - Only one site. In Puppeteer issue #4476, the reset came on one specific site’s page. Run a second site through the same setup before blaming your network.
- Works locally, resets in CI. In Playwright issue #16749, tests passed on a laptop but failed in Azure DevOps Pipelines with
page.goto: net::ERR_CONNECTION_RESET(andNS_ERROR_NET_RESETin Firefox). A Playwright team member said the error “indicates network issues” and asked whether the app was reachable from Azure at all.
Node’s fetch hides the reason one level down: undici rejects with new TypeError('fetch failed', { cause: response.error }), so the message alone tells you nothing. Log err.cause and its code: UND_ERR_SOCKET with “other side closed”, or ECONNRESET.
When the reset happens matters too. Before any response, Node’s http gives you socket hang up on the request. If the response already started, the response object emits an error with the message aborted and code ECONNRESET, and the original socket error sits in its cause. Partial data then points to a cut-off download, not an empty page.
In Python, the reason sits inside the ProtocolError. ConnectionResetError is a reset, RemoteDisconnected is a plain close. Log the inner one, since it shows which of the two you are fighting.
Open questions
No big anti-bot vendor documents resetting connections because of a TLS fingerprint. The link rests on user reports such as claude-code issue #37300. Apify’s docs warn that residential connections can drop, but Bright Data’s error list has no code for a reset, so a proxy-side reset is hard to tell apart from a site-side one.
Why it matters: a reset tells you nothing, so you have to guess the reason. If a vendor said “we reset on a bad fingerprint”, you’d swap the client at once instead of retrying.
The closest Cloudflare gets is in its HTTP DDoS protection. Its “Force Connection Close” action shuts ongoing connections and “forces the client to reconnect”. That is about floods and not fingerprints, and Cloudflare calls it an internal action you can’t use in overrides.
Apify’s advice for unstable residential sessions: use a datacenter proxy for larger requests, or plan for interruptions and build for them. Our advice: make retries part of your scraper from day one, whichever proxy you use.
Questions
What does 'socket hang up' mean in Node.js?
The connection closed before any response came back. Node's HTTP docs list it as the error you get on a premature close: message 'Error: socket hang up', code 'ECONNRESET'. Treat it like any other reset.
Why do I get ECONNRESET only now and then, not on every request?
Often a reused keep-alive connection. Node's docs say that if the server closes a kept-alive connection at the same moment your agent reuses it, the request can fail with ECONNRESET. Node's global agent keeps connections alive by default since v19. Check request.reusedSocket and retry once.
Why does the site open in my browser but reset my script?
The site may judge your client by its TLS handshake, before it reads a single header. In claude-code issue #37300, a user reported that Cloudflare rejected Node's default TLS handshake while Chrome connected fine. Clients like curl_cffi copy a real browser's handshake.
scrapenews difficulty
Not scored. We have 2 of 8 factors; a score needs 3.
| Factor | What we found | Source |
|---|---|---|
| Smallest client that gets through | a plain HTTP client | nodejs.org |
| Checks stacked | TLS fingerprint | github.com |
Our analysis of 2 sourced facts; measured runs replace them as they come. How we rate difficulty
Related
Tools that get past it
| Tool | Price |
|---|---|
| Free | |
| Free | |
| Free | |
| Free | |
| Free |
Sources
Node.js docs: Common system errors (ECONNRESET) nodejs.org
Node.js docs: HTTP (socket hang up, request.reusedSocket, http.globalAgent, agentKeepAliveTimeoutBuffer) nodejs.org
undici source: errors.js (SocketError, UND_ERR_SOCKET) github.com
undici source: client-h1.js ('other side closed') github.com
undici source: fetch/index.js (TypeError 'fetch failed' with cause) github.com
MDN: Keep-Alive header (timeout, max) developer.mozilla.org- Stack Overflow: Python requests being fingerprinted? (TLS ClientHello) stackoverflow.com
nodejs/node issue #44936: Error: read ECONNRESET github.com
Python docs: Built-in exceptions (ConnectionResetError) docs.python.org- Microsoft Learn: Windows Sockets error codes (WSAECONNRESET 10054) learn.microsoft.com
urllib3 source: connectionpool.py (ProtocolError 'Connection aborted.') github.com
urllib3 docs: Retry (read errors, allowed_methods, backoff_factor) urllib3.readthedocs.io
Requests docs: HTTPAdapter max_retries requests.readthedocs.io
oppia/oppia issue #19775: ConnectionError: ('Connection aborted.', ConnectionResetError(104, ...)) github.com
Azure/azure-cli issue #28139: ConnectionResetError: [WinError 10054] github.com
psf/requests issue #5981: ('Connection aborted.', RemoteDisconnected(...)) github.com
Chromium source: net_error_list.h (CONNECTION_RESET -101, CONNECTION_CLOSED -100, EMPTY_RESPONSE -324) chromium.googlesource.com
puppeteer/puppeteer issue #1477: page.goto() generates Error: net::ERR_CONNECTION_RESET github.com
puppeteer/puppeteer issue #4476: net::ERR_CONNECTION_RESET error github.com
anthropics/claude-code issue #37300: Cloudflare TLS fingerprint rejection (ECONNRESET/ETIMEDOUT) github.com
curl_cffi README: impersonate browser TLS/JA3 and HTTP/2 fingerprints github.com
curl_cffi docs: Quick start (impersonate="chrome") curl-cffi.readthedocs.io- HAProxy 3.2 docs: reject, silent-drop, src_conn_rate docs.haproxy.org
- Stack Overflow: CURL ERROR: Recv failure: Connection reset by peer stackoverflow.com
Bright Data docs: Proxy errors troubleshooting (client_10140) docs.brightdata.com
Apify docs: Residential proxy (sessions, connection interruptions) docs.apify.com
Cloudflare docs: JA3/JA4 fingerprint developers.cloudflare.com
Cloudflare docs: HTTP DDoS Attack Protection parameters (Connection Close, Force Connection Close) developers.cloudflare.com
microsoft/playwright issue #16749: page.goto: net::ERR_CONNECTION_RESET in Azure DevOps Pipelines github.com