W3docs

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

net::ERR_HTTP2_PROTOCOL_ERROR is an error that occurs in the Google Chrome browser when there is an issue with the HTTP/2 protocol.

net::ERR_HTTP2_PROTOCOL_ERROR is an error that occurs in the Google Chrome browser when there is an issue with the HTTP/2 protocol. This error is usually accompanied by the message "Error code: HTTP2_PROTOCOL_ERROR".

The HTTP/2 protocol is a newer version of the HTTP protocol designed to improve web communication's speed and efficiency. It allows multiple requests to be sent over a single connection and can improve the performance of websites by making it faster to load content.

If you see the net::ERR_HTTP2_PROTOCOL_ERROR error, it typically stems from server or proxy misconfigurations, TLS/ALPN negotiation failures, or malformed HTTP/2 frames. Common causes include:

  • The server or an intermediate proxy does not properly support HTTP/2 or has it misconfigured.
  • TLS/ALPN negotiation fails, causing the connection to abort during the HTTP/2 handshake.
  • A firewall, load balancer, or reverse proxy intercepts or corrupts HTTP/2 frames.
  • The client or server sends invalid HTTP/2 control frames (e.g., malformed HEADERS or SETTINGS).

If you are seeing this error and are using PHP, the issue may be related to how your code interacts with the server. For example, if you are using the curl library to make HTTP requests, it might not be explicitly configured to use HTTP/2, or the underlying libcurl may lack HTTP/2 support.

To explicitly request HTTP/2 in PHP cURL, set CURLOPT_HTTP_VERSION to CURL_HTTP_VERSION_2_0:

$ch = curl_init('https://example.com/api');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
$response = curl_exec($ch);
curl_close($ch);

If the error persists, verify that your server and PHP environment actually support HTTP/2. You can test HTTP/2 support from the command line using:

curl -I --http2 https://example.com

Alternatively, check the "Network" tab in your browser's developer tools to see the protocol version listed for the request. On the server side, ensure your web server (e.g., Nginx or Apache) has HTTP/2 enabled and that ALPN is correctly configured for TLS negotiation.