# "Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR": what it means and how to fix it

**Audit ID:** `errors-in-console` · **Category:** Best Practices

<!--QA-->
> **Quick answer:** "Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR" means Chrome aborted an HTTP/2 response because the server or a proxy reset the stream or sent something HTTP/2 forbids. The common causes are a response cut off mid-body, a connection-specific header such as Connection or Transfer-Encoding, oversized headers, or a wrong Content-Length. Reproduce it with curl --http2 -v, then fix the server or proxy.
<!--/QA-->

This console message means Chrome gave up on an HTTP/2 response partway through. Either the server, or a proxy or CDN between you and the server, reset the stream, closed it before the body finished, or sent something the HTTP/2 rules forbid. Chrome drops the whole response and logs the error. The file never loads: a script does not run, a stylesheet does not apply, an image stays blank, or an API call fails. Lighthouse surfaces the message through the audit "Browser errors were logged to the console" ([`errors-in-console`](/audits/errors-in-console)), and one row fails it. This page covers what the error means, why it often shows with a 200 status, how to find the hop that breaks it, and the fixes for each cause.

## TL;DR

- **What:** `net::ERR_HTTP2_PROTOCOL_ERROR` is Chrome's error for an HTTP/2 stream that ended badly: reset by the other side, cut off mid-body, or carrying a header or frame that HTTP/2 does not allow.
- **Why it matters:** The resource fails for real visitors too, not only in the lab. If it is a script or stylesheet, part of the page breaks.
- **Fix:** Reproduce with `curl --http2 -v`, compare with `--http1.1`, then read the error logs of each hop at that moment. The usual fixes: remove connection-specific headers, keep headers small, make `Content-Length` match the body, and stop the proxy from cutting off slow or large responses.

## What does "net::ERR_HTTP2_PROTOCOL_ERROR" mean?

HTTP/2 sends many requests over one connection, each as its own **stream**. Either side can end a stream early with an `RST_STREAM` frame and an error code, and the protocol has strict rules about which headers and frames are allowed. Chrome reports `ERR_HTTP2_PROTOCOL_ERROR` when a stream for one of your resources ends in a way it cannot accept:

| What happened | What it usually means |
|---|---|
| The server or proxy reset the stream (`RST_STREAM` with `PROTOCOL_ERROR` or `INTERNAL_ERROR`) | The server hit an error while sending the response, or a proxy gave up on its upstream |
| The stream closed before the body finished | An upstream timeout, a crashed worker, or a proxy that could not buffer the response |
| The response carried a header HTTP/2 forbids | A connection-specific header such as `Connection`, `Keep-Alive`, `Transfer-Encoding` or `Upgrade`, or an invalid header value |
| The body length did not match `Content-Length` | Middleware changed the body (compression, injection) and left the old length |

It is not a bug in your JavaScript, and it is not a DNS or certificate problem. The connection was set up fine; one response on it went wrong.

## Why does ERR_HTTP2_PROTOCOL_ERROR show with status 200?

In the DevTools Network panel the request often shows **200** with the failure next to it. The headers, including the status line, arrived intact. The stream broke later, while the body was downloading. That narrows the cause to the response body:

- **An upstream timeout.** The app streams a slow response, and a proxy or load balancer closes it at its own timeout.
- **Proxy buffering failures.** nginx buffers large upstream responses to temporary files. If the disk is full or the temp directory is not writable, it truncates the response, and HTTP/2 clients see a reset stream.
- **A wrong `Content-Length`.** The header promises more or fewer bytes than the body has, often after a plugin or middleware modified the body.
- **A crashed worker.** The process serving the request died mid-response.

A failure with no status at all points earlier: forbidden headers, oversized headers, or a reset before the response began.

## How do I find the cause?

1. **Get the exact URL.** In the Lighthouse report, expand "Browser errors were logged to the console". In DevTools, open the Network panel, reload, and look for the red row. Note the type (script, stylesheet, fetch) and whether it shows 200.
2. **Reproduce it outside the browser:**

   ```bash
   curl --http2 -sv -o /dev/null https://example.com/path/to/file.js
   ```

   At the end of the output, look for `HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)` or `INTERNAL_ERROR (err 2)`. A transfer that ends short of the size curl expected means the body was cut off.
3. **Compare with HTTP/1.1:**

   ```bash
   curl --http1.1 -sv -o /dev/null https://example.com/path/to/file.js
   ```

   If HTTP/1.1 succeeds and HTTP/2 fails, the problem is in the HTTP/2 layer of a server, CDN or proxy. If both fail, the response itself is broken.
4. **Bypass hops one at a time.** Request the origin directly (or with the CDN switched to development or bypass mode). The first hop where the error appears is the one to fix.
5. **Read the error logs at that timestamp** on the CDN, load balancer, web server and app. Look for upstream timeouts, `client intended to send too large header`, buffer or temp-file write errors, and worker crashes.
6. **For intermittent errors, record a Chrome net log.** Open `chrome://net-export`, record while reproducing, and load the file in the NetLog viewer. The HTTP/2 session events show which stream was reset and with which error code.

## How do I fix ERR_HTTP2_PROTOCOL_ERROR?

### 1. Remove connection-specific headers

HTTP/2 forbids `Connection`, `Keep-Alive`, `Proxy-Connection`, `Transfer-Encoding` and `Upgrade` in responses. A server or app that adds them by hand (common in custom middleware and older PHP code) can trigger the error. Remove them from the app; the server handles the connection itself.

### 2. Keep headers and cookies small

Very large response headers, often from piled-up `Set-Cookie` headers or a huge `Content-Security-Policy`, can exceed the limits of the server, proxy or browser. Trim cookies, combine policies, and raise the header size limit on the proxy only if the size is legitimate.

### 3. Make Content-Length match the body, or drop it

If a plugin, compression layer or HTML injector changes the body after `Content-Length` is set, the length is wrong. Let the server compute the length, or remove the header and let HTTP/2 framing end the body.

### 4. Stop the proxy from cutting off responses

- Raise upstream read timeouts on the proxy or load balancer for endpoints that are legitimately slow, or make them faster.
- Check free disk space and the temp directory permissions on nginx or other buffering proxies.
- Look for workers that crash or are killed for memory during large responses.

### 5. Update or reconfigure the server or CDN

Old HTTP/2 implementations have had bugs that surface as this error. Update nginx, Apache, your load balancer or the CDN configuration. As a temporary measure to confirm the diagnosis, turning HTTP/2 off at one hop and seeing the error vanish proves where it lives. Do not leave HTTP/2 off as the fix.

## Can the visitor's computer cause it?

Yes, for that one visitor. Antivirus suites that inspect HTTPS traffic, some corporate proxies and VPNs, and rarely a browser extension sit in the middle and can break HTTP/2 streams. The sign is an error only one person sees. Ask them to try another network, another browser profile, or with HTTPS scanning turned off. If the row shows in [PageSpeed Insights](https://pagespeed.web.dev), Lighthouse CI or the audit at lighthouse-md.com, which run in a clean Chrome on Google's network, the cause is on your side.

## How do I fix it on WordPress, Shopify, or Next.js?

- **WordPress:** the usual causes are a caching or optimization plugin that rewrites the HTML and leaves a stale `Content-Length`, PHP timeouts on slow admin-ajax or REST calls, and hosts whose nginx proxy runs out of buffer space. Disable optimization plugins one at a time and check the PHP and nginx error logs.
- **Shopify:** the platform runs the servers, so a row usually comes from a third-party app or script host, not your store. Read the failing URL. If it is an app domain, report the exact URL and error to the app developer; if it is a Shopify CDN URL, re-test later and contact support if it persists.
- **Next.js and Node servers:** check custom middleware for hand-set `Connection` or `Transfer-Encoding` headers, streaming responses that a proxy in front times out, and serverless functions that hit their time limit mid-stream.

## How do I verify the fix?

1. Run the `curl --http2 -v` command again. It should complete with no "not closed cleanly" line.
2. Re-run Lighthouse. The row should be gone from "Browser errors were logged to the console". If it was the only error, the audit passes.
3. For an intermittent error, watch the server and proxy logs for a day. One clean run proves little when the cause is a timeout under load.

## What mistakes should I avoid?

- **Clearing the browser cache and calling it fixed.** The error comes from the response, not the cache. If it vanished, the server condition changed.
- **Turning HTTP/2 off for good.** It hides the problem and costs every visitor the multiplexing HTTP/2 gives.
- **Blaming the page code.** No JavaScript change on the page can fix a stream the server resets.
- **Reading a single visitor's report as a site outage.** Check whether it reproduces from a clean network first.

## Related audits

- [Browser errors were logged to the console](/audits/errors-in-console): the audit this message fails, with the other common console errors
- [Failed to load resource: net::ERR_BLOCKED_BY_CLIENT](/audits/err-blocked-by-client): the other `net::` error, where the browser cancels the request instead
- [Enable text compression](/audits/enable-text-compression): compression middleware is a common source of a wrong `Content-Length`

---

Audit your URL at https://lighthouse-md.com.
