Errors & CAPTCHAs

ERR_HTTP2_PROTOCOL_ERROR when scraping: causes and fixes

HTTP status codes · ERR_HTTP2_PROTOCOL_ERROR
Published

What you see

  • net::ERR_HTTP2_PROTOCOL_ERROR
  • Error: net::ERR_HTTP2_PROTOCOL_ERROR at
  • playwright._impl._api_types.Error: net::ERR_HTTP2_PROTOCOL_ERROR
  • (failed)net::ERR_HTTP2_PROTOCOL_ERROR
More error strings (9)
  • HTTP2_PROTOCOL_ERROR -337
  • curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)
  • HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
  • CURLE_HTTP2_STREAM
  • httpx.RemoteProtocolError: <StreamReset stream_id:1, error_code:ErrorCodes.INTERNAL_ERROR, remote_reset:True>
  • httpcore.RemoteProtocolError: <StreamReset stream_id:1, error_code:ErrorCodes.INTERNAL_ERROR, remote_reset:True>
  • Error [ERR_HTTP2_STREAM_ERROR]: Stream closed with error code NGHTTP2_PROTOCOL_ERROR
  • Stream closed with error code NGHTTP2_INTERNAL_ERROR
  • HTTP/2 connection error (PROTOCOL_ERROR): Request headers too long.

What it means

The site set up an HTTP/2 connection with you, then killed your request in the middle. Chrome got a “stop” signal for that request, or data it could not read, and gave up. You get no status code and no page. When you scrape, the site often does it on purpose.

Why it happens

The usual causes, most common first:

  1. The site spotted your headless browser. Playwright issue #27600 and Puppeteer issue #11638 both fail in headless mode and work with a visible window. On Adobe’s site, a Puppeteer maintainer said Adobe “has a way to prevent automation”.
  2. Your HTTP/2 fingerprint gives you away. Every client opens HTTP/2 a little differently: which settings it sends and in what order, and how it orders the first request lines. Akamai’s research says this can catch a scraper that sends a Chrome User-Agent but isn’t Chrome.
  3. The server is broken. Sometimes nobody is blocking you. In curl issue #14620, a server sent data that made no sense, and curl hung up with PROTOCOL_ERROR.
  4. Your headers or cookies are too big. One ASP.NET server closed the connection with HTTP/2 connection error (PROTOCOL_ERROR): Request headers too long. A huge cookie caused it.

HTTP/2 carries many requests over one connection, and each request is a “stream”. A server can end one stream with an error code (a RST_STREAM frame) and keep the rest of the connection alive.

The fingerprint comes from the very first frames. Akamai’s paper found that clients differ in which SETTINGS they send, their order and values, the WINDOW_UPDATE size and PRIORITY frames, and the order of the pseudo-headers (:method, :authority, :scheme, :path). It adds that many HTTP clients can’t change these details at all.

The lwthiker blog says anti-bot tools use HTTP/2 fingerprints to block scripts and let real browsers through. Its author saw curl-impersonate blocked before it copied Chrome’s HTTP/2.

Not every reset is a block. In Node.js issue #50660, a Node.js team member called one case “a problem with the server” and added that “curl barfs on it too”.

Fix it

  1. Open the URL in a normal Chrome. Works there but fails in your script? The site is judging the client.
  2. Test with curl, both ways. Run curl -v --http2 <url>, then curl -v --http1.1 <url>. If only HTTP/2 fails, the server’s HTTP/2 is to blame.
  3. Send a real User-Agent from headless Chrome. That fixed Playwright issue #27600. In that issue, the headless User-Agent said HeadlessChrome, and the site could see that.
  4. Clean the sec-ch-ua header too. In the same issue, one user kept failing with a good User-Agent. Removing "HeadlessChrome" from sec-ch-ua fixed it.
  5. For HTTP clients: copy a browser’s fingerprint. curl_cffi can copy Chrome’s HTTP/2 settings and request-line order: curl_cffi.get(url, impersonate="chrome").
  6. Try HTTP/1.1. Chrome has a --disable-http2 switch and curl has --http1.1. This fixes broken servers, not blocks.
  7. Trim your cookies. If you carry a big cookie jar from page to page, start a fresh session and retry.

Why step 2 works: curl takes your browser out of the picture. If --http1.1 loads and --http2 fails, the server’s HTTP/2 is broken for everyone. That was curl issue #14620, where --http1.1 worked and the issue was labelled “not a curl bug”.

Why step 6 often fails: a site that blocks automation blocks it on any protocol. In Puppeteer issue #13175, --disable-http2 didn’t help, and a Puppeteer maintainer said the page “detects the automation and blocks access”. In changedetection.io discussion #2051, forcing HTTP/1.1 “made no difference” either.

What did work there: one user set a normal Chrome User-Agent in the request headers and turned on the stealth setting of their browser container.

On step 5, our advice: changing only the User-Agent in an HTTP client makes the mismatch worse. Akamai’s paper uses exactly that mismatch to catch scrapers.

Paste this into your AI

My scraper fails with an HTTP/2 error:
"<paste the exact error line, e.g. net::ERR_HTTP2_PROTOCOL_ERROR or curl: (92) ...>"
Explain in plain words who broke the HTTP/2 stream: the site on purpose, a server bug, or my client.
List the likely causes in order, most likely first: headless browser detected,
HTTP/2 fingerprint that doesn't match my User-Agent, a buggy server, headers or cookies too big.
For each cause, give one quick test and one fix.
Show curl -v commands that test the same URL with --http2 and with --http1.1.
My setup: <Puppeteer / Playwright / curl / httpx / Node + version>,
headless: <yes / no>, User-Agent I send: <default / custom>,
proxy: <none / provider + type>,
does the URL open in a normal Chrome on the same network? <yes/no>,
does it fail every time or now and then? <every time / sometimes>.

Dev details

What each tool prints

tool error
Chrome, Puppeteer Error: net::ERR_HTTP2_PROTOCOL_ERROR at https://…
Playwright (Python) playwright._impl._api_types.Error: net::ERR_HTTP2_PROTOCOL_ERROR
Chrome DevTools, Network tab (failed)net::ERR_HTTP2_PROTOCOL_ERROR
curl curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
Python httpx httpx.RemoteProtocolError: <StreamReset stream_id:1, error_code:ErrorCodes.INTERNAL_ERROR, remote_reset:True>
Node.js http2 Error [ERR_HTTP2_STREAM_ERROR]: Stream closed with error code NGHTTP2_PROTOCOL_ERROR
ASP.NET Kestrel (server log) HTTP/2 connection error (PROTOCOL_ERROR): Request headers too long.

Chromium’s definition

// There is an HTTP/2 protocol error.
NET_ERROR(HTTP2_PROTOCOL_ERROR, -337)

Why Chrome shows one error for many causes

When a server ends a stream, Chrome checks the code the server sent. Only three codes get their own error. Every other code becomes ERR_HTTP2_PROTOCOL_ERROR. From Chromium’s spdy_session.cc (shortened):

if (error_code == spdy::ERROR_CODE_NO_ERROR) {
  CloseActiveStreamIterator(it, ERR_HTTP2_RST_STREAM_NO_ERROR_RECEIVED);
} else if (error_code == spdy::ERROR_CODE_REFUSED_STREAM) {
  CloseActiveStreamIterator(it, ERR_HTTP2_SERVER_REFUSED_STREAM);
} else if (error_code == spdy::ERROR_CODE_HTTP_1_1_REQUIRED) {
  // ... ERR_HTTP_1_1_REQUIRED
} else {
  it->second->LogStreamError(ERR_HTTP2_PROTOCOL_ERROR, "Server reset stream.");
  // TODO(mbelshe): Map from Spdy-protocol errors to something sensical.
  // For now, it doesn't matter much - it is a protocol error.
  CloseActiveStreamIterator(it, ERR_HTTP2_PROTOCOL_ERROR);
}

So a server that sends INTERNAL_ERROR shows up in curl as INTERNAL_ERROR (err 2), but in Chrome as ERR_HTTP2_PROTOCOL_ERROR. To see the real code: test the same URL with curl -v.

Headless fixes (Playwright, Python)

The solution from Playwright issue #27600:

ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.81"
page = browser.new_page(user_agent=ua)

Chromium’s own list includes a switch to turn HTTP/2 off:

browser = p.chromium.launch(args=["--disable-http2"])

HTTP clients: copy the browser

import curl_cffi

r = curl_cffi.get("https://example.com/page", impersonate="chrome")

Akamai’s fingerprint format is S[;]|WU|P[,]#: the SETTINGS values, the WINDOW_UPDATE size and then priority details. Its sample for Chrome 58 on macOS was 1:65536;3:1000;4:6291456|15663105|0.

Pseudo-header order, from the same paper:

client order
Chrome 58 :method, :authority, :scheme, :path
Firefox 53 :method, :path, :authority, :scheme
curl 7.54.0 :method, :path, :scheme, :authority
Go-http-client 2.0 :authority, :method, :path, :scheme

curl_cffi lets you assign each part by hand: CURLOPT_HTTP2_PSEUDO_HEADERS_ORDER (e.g. masp), CURLOPT_HTTP2_SETTINGS and CURLOPT_HTTP2_WINDOW_UPDATE.

curl has two HTTP/2 errors: CURLE_HTTP2 (16) for the framing layer in general and CURLE_HTTP2_STREAM (92) for one stream.

In Node.js, undici’s docs list allowH2 as on by default, so plain fetch-style code can hit HTTP/2 errors too. In undici issue #5586, undici 8.7.0 failed with Stream closed with error code NGHTTP2_INTERNAL_ERROR.

HTTPX keeps HTTP/2 off unless you turn it on (http2=True). If you did, turning it off is a fast check.

This is not Chromium’s only HTTP/2 error. The others mean something narrower: ERR_HTTP2_SERVER_REFUSED_STREAM (-351), ERR_HTTP2_PING_FAILED (-352), ERR_HTTP2_FLOW_CONTROL_ERROR (-361), ERR_HTTP2_FRAME_SIZE_ERROR (-362), ERR_HTTP2_COMPRESSION_ERROR (-363), ERR_HTTP_1_1_REQUIRED (-365) and ERR_PROXY_HTTP_1_1_REQUIRED (-366). Chrome also uses ERR_HTTP2_PROTOCOL_ERROR when it can’t read a frame the server sent, not only when the server resets a stream.

Open questions

No proxy provider documents HTTP/2 stream errors as a proxy fault, so a proxy-only failure is hard to pin down. Akamai’s docs name deny, tarpit and challenge as Bot Manager actions but don’t say which one ends in a killed HTTP/2 stream.

Why the proxy question matters: Akamai’s paper describes a proxy that doesn’t unpack TLS or rewrite HTTP/2. The site still sees your client’s own HTTP/2 fingerprint through it. Our advice: don’t expect a new IP alone to hide a headless browser or a Python client.

One odd case points the other way. In HTTPX discussion #3462, a request that failed with StreamReset worked when routed through mitmproxy.

Why the vendor question matters: if anti-bot companies said “we reset streams on a bad fingerprint”, you could skip retries and fix the client right away. Until then, the link rests on user reports and maintainer comments.

Questions

Why does my page load in headful mode but fail with ERR_HTTP2_PROTOCOL_ERROR in headless mode?

The site treats headless Chrome differently. In Playwright issue #27600, a Playwright team member said any page can decide to behave differently for headed and headless browsers. Changing the user agent fixed it for the reporter.

Does --disable-http2 fix ERR_HTTP2_PROTOCOL_ERROR?

Only when the problem is HTTP/2 itself, like a buggy server. When the site is blocking automation, it doesn't: in Puppeteer issue #13175 and changedetection.io discussion #2051, forcing HTTP/1.1 made no difference.

What does curl error 92 mean?

CURLE_HTTP2_STREAM: a stream error in the HTTP/2 framing layer. curl prints it as 'HTTP/2 stream 1 was not closed cleanly', followed by the code the other side sent, like PROTOCOL_ERROR or INTERNAL_ERROR.

scrapenews difficulty

Not scored. We have 2 of 8 factors; a score needs 3.

FactorWhat we foundSource
Smallest client that gets througha headless browsergithub.com
Checks stackedheader and HTTP/2 fingerprintblackhat.com

Our analysis of 2 sourced facts; measured runs replace them as they come. How we rate difficulty

Tools that get past it

ToolPrice
curl_cffi: Python HTTP client on curl-impersonate that can copy a browser's TLS, JA3 and HTTP/2 fingerprints.Free
curl-impersonate: Special build of curl that looks like Chrome or Firefox at the TLS and HTTP/2 level.Free
HTTPX: Python HTTP client with sync and async APIs and HTTP/2 support.Free
Playwright: Microsoft's framework to drive Chromium, Firefox and WebKit from code with one API. Made for testing; also used to scrape.Free
Puppeteer: JavaScript library to control Chrome and Firefox from code.Free

Sources

  1. Chromium source: net_error_list.h (HTTP2_PROTOCOL_ERROR, -337) chromium.googlesource.com
  2. Chromium source: spdy_session.cc (server RST_STREAM → ERR_HTTP2_PROTOCOL_ERROR) chromium.googlesource.com
  3. Chromium source: network_switch_list.h (--disable-http2) chromium.googlesource.com
  4. Playwright docs: BrowserType.launch (args) playwright.dev
  5. microsoft/playwright issue #27600: Headless mode ERR_HTTP2_PROTOCOL_ERROR github.com
  6. puppeteer/puppeteer issue #11638: net::ERR_HTTP2_PROTOCOL_ERROR in headless mode github.com
  7. puppeteer/puppeteer issue #13175: request fails with net::ERR_HTTP2_PROTOCOL_ERROR github.com
  8. changedetection.io discussion #2051: net::ERR_HTTP2_PROTOCOL_ERROR via Playwright github.com
  9. Akamai white paper: Passive Fingerprinting of HTTP/2 Clients (Black Hat EU 2017) blackhat.com
  10. lwthiker: HTTP/2 fingerprinting lwthiker.com
  11. curl_cffi docs: Impersonate guide (Akamai HTTP/2 fingerprint options) curl-cffi.readthedocs.io
  12. encode/httpx discussion #3462: StreamReset on HTTP/2-only sites github.com
  13. HTTPX docs: HTTP/2 support python-httpx.org
  14. libcurl docs: error codes (CURLE_HTTP2, CURLE_HTTP2_STREAM 92) curl.se
  15. curl/curl issue #14620: HTTP/2 stream was not closed cleanly: PROTOCOL_ERROR for 416 github.com
  16. nodejs/node issue #50660: Request fails with NGHTTP2_PROTOCOL_ERROR github.com
  17. undici docs: Client (allowH2) github.com
  18. nodejs/undici issue #5586: Stream closed with error code NGHTTP2_INTERNAL_ERROR github.com
  19. Stack Overflow: HTTP/2 connection error (PROTOCOL_ERROR): Request headers too long stackoverflow.com
  20. Stack Overflow: What's the net::ERR_HTTP2_PROTOCOL_ERROR about? stackoverflow.com
  21. Akamai TechDocs: Handle adversarial bots (deny, tarpit, challenge) techdocs.akamai.com