214

I'm currently working on a website, which triggers a net::ERR_HTTP2_PROTOCOL_ERROR 200 error on Google Chrome. I'm not sure exactly what can provoke this error, I just noticed it pops out only when accessing the website in HTTPS. I can't be 100% sure it is related, but it looks like it prevents JavaScript to be executed properly.

For instance, the following scenario happens :

  1. I'm accessing the website in HTTPS

  2. My Twitter feed integrated via https://publish.twitter.com isn't loaded at all

  3. I can notice in the console the ERR_HTTP2_PROTOCOL_ERROR

  4. If I remove the code to load the Twitter feed, the error remains

  5. If I access the website in HTTP, the Twitter feed appears and the error disappears

Google Chrome is the only web browser triggering the error: it works well on both Edge and Firefox. (NB: I tried with Safari, and I have a similar kcferrordomaincfnetwork 303 error)

I was wondering if it could be related to the header returned by the server since there is this '200' mention in the error, and a 404 / 500 page isn't triggering anything.

Thing is the error isn't documented at all. Google search gives me very few results. Moreover, I noticed it appears on very recent Google Chrome releases; the error doesn't pop on v.64.X, but it does on v.75+ (regardless of the OS; I'm working on Mac tho).


Might be related to Website OK on Firefox but not on Safari (kCFErrorDomainCFNetwork error 303) neither Chrome (net::ERR_SPDY_PROTOCOL_ERROR)


Findings from further investigations are the following:

  • error doesn't pop on the exact same page if server returns 404 instead of 2XX
  • error doesn't pop on local with a HTTPS certificate
  • error pops on a different server (both are OVH's), which uses a different certificate
  • error pops no matter what PHP version is used, from 5.6 to 7.3 (framework used : Cakephp 2.10)

As requested, below is the returned header for the failing ressource, which is the whole web page. Even if the error is triggering on each page having a HTTP header 200, those pages are always loading on client's browser, but sometimes an element is missing (in my exemple, the external Twitter feed). Every other asset on the Network tab has a success return, except the whole document itself. line that failed in console

Google Chrome header (with error):

Chrome header

Firefox header (without error):

Firefox header

A curl --head --http2 request in console returns the following success:

HTTP/2 200 
date: Fri, 04 Oct 2019 08:04:51 GMT
content-type: text/html; charset=UTF-8
content-length: 127089
set-cookie: SERVERID31396=2341116; path=/; max-age=900
server: Apache
x-powered-by: PHP/7.2
set-cookie: xxxxx=0919c5563fc87d601ab99e2f85d4217d; expires=Fri, 04-Oct-2019 12:04:51 GMT; Max-Age=14400; path=/; secure; HttpOnly
vary: Accept-Encoding

Trying to go deeper with the chrome://net-export/ and https://netlog-viewer.appspot.com tools is telling me the request ends with a RST_STREAM :

t=123354 [st=5170]    HTTP2_SESSION_RECV_RST_STREAM
                      --> error_code = "2 (INTERNAL_ERROR)"
                      --> stream_id = 1

For what I read in this other post, "In HTTP/2, if the client wants to abort the request, it sends a RST_STREAM. When the server receives a RST_STREAM, it will stop sending DATA frames to the client, thereby stopping the response (or the download). The connection is still usable for other requests, and requests/responses that were concurrent with the one that has been aborted may continue to progress. [...] It is possible that by the time the RST_STREAM travels from the client to the server, the whole content of the request is in transit and will arrive to the client, which will discard it. However, for large response contents, sending a RST_STREAM may have a good chance to arrive to the server before the whole response content is sent, and therefore will save bandwidth."

The described behavior is the same as the one I can observe. But that would mean the browser is the culprit, and then I wouldn't understand why it happens on two identical pages with one having a 200 header and the other a 404 (same goes if I disable JS).

10
  • aboutssl.org/fix-google-chrome-error-err_ssl_protocol_error that's one out of 110 results - Oct 3, 2019 at 8:26
  • I've been here obviously, and there are only client-side related answers, which can't be a solution.
    – Tristan G
    Oct 3, 2019 at 8:34
  • does the error occur in non-chrome browsers? if not, how is it not a client-side (specifically the Chrum browser) issue? Oct 3, 2019 at 8:38
  • 1
    Likely a malformed HTTP response headers. Is the whole site not loading? Or just one or more assets? Can you edit the question to include the HTTP response headers shown in the http response for an asset that doesn’t load when using HTTP/2? And also the for Edge/Firefox where it works? Oct 3, 2019 at 18:41
  • 1
    Can't see anything wrong there so suspect it's not the main request. Also ignore the cookies thing - it's not that. Try this to see if you can figure t out: michalspacek.com/… Oct 4, 2019 at 12:01

42 Answers 42

96

In my case it was - no disk space left on the web server.

4
  • 1
    interesting, for me the same, front webserver had disk full. seems like nginx does not catch this situation because there was nothing noticable in log. Mar 28, 2020 at 16:34
  • 12
    Just to explain to anyone who is wondering why this results in a protocol error, because we also got something similar and were left wondering what's going on. The issue is that when there's no disk space left on the disk, some webservers (nginx definitely but maybe apache as well) are unable to send an entire response and usually just drop the request after the first "chuck" of the response is sent. This results in the content length header to not match the actual content received. This (as mentioned by @Xtendo) can result in an http2 protocol error.
    – apokryfos
    Sep 24, 2020 at 14:56
  • 1
    Thank you for this. I had the same issue (nginx). We were not out of space, but it was 90% full. This issue was happening only on pages with a lot of content (large reports with 600+ rows of content in a table). Increasing the disk size in AWS solved the problem immediately. Dec 19, 2021 at 20:51
  • Same here for .net core app hosted on linux server. nginx creates temp files on requests which needs to load data from sql and as @BrandonRohde told, it happened usually in large data contained pages.
    – Mehdi
    Jul 20, 2022 at 7:10
46

The fix for me was setting minBytesPerSecond in IIS to 0. This setting can be found in system.applicationHost/webLimits in IIS's Configuration Editor. By default it's set to 240.

enter image description here

It turns out that some webservers will cut the connection to a client if the server's data throughput to the client passes below a certain limit. This is to protect against "slow drip" denial of service attacks. However, this limit can also be triggered in cases where an innocent user requests many resources all at once (such as lots of images on a single page), and the server is forced to ration the bandwidth for each request so much that it causes one or more requests to drop below the throughput limit, which causes the server to cut the connection and shows up as net::ERR_HTTP2_PROTOCOL_ERROR in Chrome.

For example, let's say you request 10 GIF images all at once, and each GIF is 10 megabytes (100MB total). If your download speed from the server is 1MB per second, your browser will have to divide that 1MBps amongst the 10 images somehow. Now, here is where it gets interesting, as how the bandwidth gets divided seems to be random:

  1. Your browser may divide the bandwidth equally across the images, resulting in 0.1MBps allocated to each image. None of the download speeds fall below the default IIS minBytesPerSecond limit of 240 bytes, so all the GIFs download successfully.
  2. Your browser may prioritize the first 5 at 0.2MBps, and put the last 5 "on hold" at 0MBps, to be downloaded after the first 5. However, since 0MBps is below the default IIS minBytesPerSecond limit of 240 bytes, the server cuts the connection to the remaining downloads.

I was able to stop the connections from being cut by following these steps:

  1. I used Chrome's Network Log Export tool at chrome://net-export/ to see exactly what was behind the ERR_HTTP2_PROTOCOL_ERROR error. I started the log, reproduced the error, and stopped the log.
  2. I imported the log into the log viewer at https://netlog-viewer.appspot.com/#import, and saw an interesting event titled HTTP2_SESSION_RECV_RST_STREAM, with error code 8 (CANCEL).

enter image description here

  1. I did some Googling on the term "RST_STREAM" (which appears to be an abbreviated form of "reset stream") and found a discussion between some people talking about an IIS setting called minBytesPerSecond (discussion here: https://social.msdn.microsoft.com/Forums/en-US/aeb01c46-bcdf-40ed-a417-8a3558221137). I also found another discussion where there was some debate about whether minBytesPerSecond was intended to protect against slow HTTP DoS (slow drip) attacks (discussion here: IIS 8.5 low minBytesPerSecond not working against slow HTTP POST). In any case, I learned that IIS uses minBytesPerSecond to determine whether to cancel a connection if it cannot sustain the minimum throughput. This is relevant in cases where a single user makes many requests to a large resource, and each new connection ends up starving all the other unfinished ones, to the point where some may fall below the minBytesPerSecond threshold.
  2. To confirm that the server was canceling requests due to a minBytesPerSecond error, I checked my server's HTTPERR log at c:\windows\system32\logfiles\httperr. Sure enough, I opened the file and did a text search for "MinBytesPerSecond" and there were tons of entries for it.

enter image description here

  1. So after I changed the minBytesPerSecond to 0, I was no longer able to reproduce the ERR_HTTP2_PROTOCOL_ERROR error. So, it appears that the ERR_HTTP2_PROTOCOL_ERROR error was being caused by my server (IIS) canceling the request because the throughput rate from my server fell below the minBytesPerSecond threshold.

So for all you reading this right now, if you're not using IIS, maybe there is a similar setting related to minimum throughput rate you can play with to see if it gets rid of the ERR_HTTP2_PROTOCOL_ERROR error.

1
31

I am finally able to solve this error after researching some things I thought is causing the error for 24 errors. I visited all the pages across the web. And I am happy to say that I have found the solution. If you are using NGINX, then set gzip to off and add proxy_max_temp_file_size 0; in the server block like I have shown below.

 server {
  ...
  ...
  gzip off;
  proxy_max_temp_file_size 0;
  location / {
    proxy_pass http://127.0.0.1:3000/;
  ....

Why? Because what actually happening was all the contents were being compressed twice and we don't want that, right?!

5
  • 3
    Appreciate this! I think turning gzip off in my particular case was the missing step. I am running an express app behind nginx, and would only get the error on the .css/.js, not always either, maybe 1/2 the time. This did the trick!
    – Kingsley
    Oct 9, 2020 at 0:21
  • 5
    Just proxy_max_temp_file_size 0; statement work fine for me. Dec 4, 2020 at 13:08
  • I had this problem with Vite and it caused pages to no load with messages of missing source maps. Thank you!
    – gboone
    Jun 4, 2022 at 14:05
  • gzip makes transferring files faster. Any workarounds here?
    – qwertynik
    Aug 10, 2022 at 12:50
  • In my case, gzip was happening twice, and hence I set it off here. Aug 11, 2022 at 13:17
30

For several weeks I was also annoyed by this "bug":

net :: ERR_HTTP2_PROTOCOL_ERROR 200

In my case, it occurred on images generated by PHP.

It was at header() level, and on this one in particular:

header ('Content-Length:'. Filesize($cache_file));

It did obviously not return the exact size, so I deleted it and everything works fine now.

So Chrome checks the accuracy of the data transmitted via the headers, and if it does not correspond, it fails.

EDIT

I found why content-length via filesize was being miscalculated: the GZIP compression is active on the PHP files, so excluding the file in question will fix the problem. Put this code in the .htaccess:

SetEnvIfNoCase Request_URI ^ / thumb.php no-gzip -vary

It works and we keep the header Content-length.

5
  • 1
    Great you saved me !!! But I still don't understand the real problem, in my case the error only happens in https but not in http.
    – Nico
    Dec 2, 2019 at 9:29
  • Hello @Nico , yes, I think it's normal, the verification between the announced size and that of the file downloaded by the browser (Chrome) should only be done in the https protocol. Very happy that this solution could help you!
    – Xtendo
    Dec 3, 2019 at 10:35
  • 1
    Somehow I managed to use "Content -Length" instead of "Content-Length". After removing the space, it worked. Thank you. Mar 18, 2020 at 13:38
  • 2
    I had a problem with Livewire not loading its JS in shared hosting, while I could open the same path in the browser without problem. I don't understand why this worked, but it did. Black magic. Thank you. Sep 15, 2021 at 10:50
  • 1
    > It did obviously not return the exact size, so I deleted it and everything works fine now. This fix worked for me. In C# I did this: ``` result.Content.Headers.ContentLength = null; ```
    – mghaoui
    Dec 17, 2021 at 9:59
18

I experienced a similar problem, I was getting ERR_HTTP2_PROTOCOL_ERROR on one of the HTTP GET requests.

I noticed that the Chrome update was pending, so I updated the Chrome browser to the latest version and the error was gone next time when I relaunched the browser.

2
  • 1
    Me too, and this answer is the only one that makes sense, because it's not specific to a single website, or a site I own, but just arbitrary sites. Jun 16, 2020 at 19:35
  • This is not the only possible source of this problem. But it's good to check if you have the last version. Jul 31 at 14:56
9

I encountered this because the http2 server closed the connection when sending a big response to the Chrome.

Why? Because it is just a setting of the http2 server, named WriteTimeout.

0
9

I didn't figure out what exactly was happening, but I found a solution.

The CDN feature of OVH was the culprit. I had it installed on my host service but disabled for my domain because I didn't need it.

Somehow, when I enable it, everything works.

I think it forces Apache to use the HTTP2 protocol, but what I don't understand is that there indeed was an HTTP2 mention in each of my headers, which I presume means the server was answering using the right protocol.

So the solution for my very particular case was to enable the CDN option on all concerned domains.

If anyone understands better what could have happened here, feel free to share explanations.

0
7

I had this problem when having a Nginx server that exposing the node-js application to the external world. The Nginx made the file (css, js, ...) compressed with gzip and with Chrome it looked like the same.

The problem solved when we found that the node-js server is also compressed the content with gzip. In someway, this double compressing leading to this problem. Canceling node-js compression solved the issue.

1
  • 34
    It is interesting to see that several persons have answered this post already, and each time the root of the problem was something different. I think this error is quite confusing indeed.
    – Tristan G
    Nov 27, 2019 at 13:36
4

We experienced this problem on pages with long Base64 strings. The problem occurs because we use CloudFlare.

Details: https://community.cloudflare.com/t/err-http2-protocol-error/119619.

Key section from the forum post:

After further testing on Incognito tabs on multiple browsers, then doing the changes on the code from a BASE64 to a real .png image, the issue never happened again, in ANY browser. The .png had around 500kb before becoming a base64,so CloudFlare has issues with huge lines of text on same line (since base64 is a long string) as a proxy between the domain and the heroku. As mentioned before, directly hitting Heroku url also never happened the issue.

The temporary hack is to disable HTTP/2 on CloudFlare.

Hope someone else can produce a better solution that doesn't require disabling HTTP/2 on CloudFlare.

1
  • We experience same thing but not because of cloudflare: we just had too many long base64 string image
    – nemo
    May 6, 2021 at 14:59
4

My problem was that my access token was too large, making the header also too large, so I refactored its content to fix the error

1
  • 2
    This was my issue too. I had multiple sites running on localhost all storing cookies there. You only need a handful of access tokens to exceed the default 16KB maxrequestbytes setting.
    – ajbeaven
    Apr 18 at 1:57
3

I faced this error several times and, it was due to transferring large resources(larger than 3MB) from server to client.

3
  • Have you got any resolution on that? If yes can please share how you resolved it.
    – UtkarshaG
    Oct 15, 2020 at 15:48
  • @UtkarshaG compressed and minified css,js files.
    – fbarikzehy
    Oct 15, 2020 at 19:21
  • 2
    this is happening to me because I have a select2 with ~4000 SelectListItems (Key-value pairs) in it. Out of nowhere, I just started getting the HTTP2 protocol error on first load. When I hit refresh page loads fine on second time. I'm only passing 193kb of data but maybe protocol doesn't like huge select lists.
    – Michael G
    Jun 25, 2021 at 21:03
3

This error is currently being fixed: https://chromium-review.googlesource.com/c/chromium/src/+/2001234

But it helped me, changing nginx settings:

  • turning on gzip;
  • add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  • expires off;

In my case, Nginx acts as a reverse proxy for Node.js application.

1
3

Just posting here to let people know that ERR_HTTP2_PROTOCOL_ERROR in Chrome can also be caused by an unexpected response to a CORS request.

In our case, the OPTIONS request was successful, but the following PUT that should upload an image to our infrastructure was denied with a 410 (because of a missing configuration allowing uploads) resulting in Chrome issuing a ERR_HTTP2_PROTOCOL_ERROR.

When checking in Firefox, the error message was much more helpful:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.[...] (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 410.

My recommendation would be to check an alternative browser in this case.

2

In our case, the reason was invalid header. As mentioned in Edit 4:

  • take the logs
  • in the viewer choose Events
  • chose HTTP2_SESSION

Look for something similar:

HTTP2_SESSION_RECV_INVALID_HEADER

--> error = "Invalid character in header name."

--> header_name = "charset=utf-8"

2

By default nginx limits upload size to 1MB.

With client_max_body_size you can set your own limit, as in

location /uploads {
    ...
    client_max_body_size 100M;
} 

You can set this setting also on the http or server block instead (See here).

This fixed my issue with net::ERR_HTTP2_PROTOCOL_ERROR

2

In my case net::ERR_HTTP2_PROTOCOL_ERROR 200 was caused by (AWS) load balancer that terminates idle connections after 60 seconds.

If no data has been sent or received by the time that the idle timeout period elapses, the load balancer closes the connection. To ensure that lengthy operations such as file uploads have time to complete, send at least 1 byte of data before each idle timeout period elapses, and increase the length of the idle timeout period as needed.

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout

And terminated connection was a long polling endpoint, that sends no data if there is no events on the backend. More about this on this blog post https://mvysny.github.io/Vaadin8-push-issues/ which helped me a lot.

The solution that I used was setting context param pushLongPollingSuspendTimeout to 58000 in web.xml

3
  • I think I have the same issue. Do you have a good fix? Either A) what ALB idle timeout do I need to keep the browser happy? or B) what setting do I change to make the browser not try to keep idle connections for more than 60s?
    – Rich
    Jul 5 at 8:49
  • 1
    @Rich see updated answer
    – user11153
    Jul 5 at 9:41
  • 1
    Thanks! My client is a web browser (+ some kind of corporate HTTP proxy) and my server is Scala Play (no long polling) so I'll have to look for something else to change, but thanks for updating.
    – Rich
    Jul 5 at 9:54
1

I hit this issue working with Server Sent Events. The problem was solved when I noticed that the domain name I used to initiate the connection included a trailing slash, e.g. https://foo.bar.bam/ failed with ERR_HTTP_PROTOCOL_ERROR while https://foo.bar.bam worked.

4
  • I also have the error message after SSE runs for a while and then suddenly it appears in the Chrome dev console. The trailing slash is, unfortunately, not the solution.
    – Avatar
    Mar 24, 2022 at 9:10
  • I'm pretty sure it depends on how the server handles routing. I haven't yet looked into these controls from within node / express Mar 25, 2022 at 20:36
  • I am still trying to figure out what's going on. Since there is often a 504 timeout in the console, I guess that the PHP script aborts due to the limit of the execution time. For debugging I started to catch as many errors as possible and echo according messages to the frontend. Because each error/exception stops the SSE PHP script.
    – Avatar
    Mar 26, 2022 at 6:22
1

I'm not convinced this was the issue but through cPanel I'd noticed the PHP version was on 5.6 and changing it to 7.3 seemed to fix it. This was for a WordPress site. I noticed I could access images and generic PHP files but loading WordPress itself caused the error.

1
  • And yet, thank you for posting this Ric! This solved my problem. I was on 7.2, and moving it to 7.4 fixed it. Something weird WordPress must be doing. Jul 31, 2021 at 22:29
1

Seems like many issues may cause ERR_HTTP2_PROTOCOL_ERROR: in my case it was a minor syntax error in a php-generated header, Content-Type : text/plain . You might notice the space before the colon... that was it. Works no problem when the colon is right next to the header name like Content-Type: text/plain. Only took a million hours to figure out... The error happens with Chrome only, Firefox loaded the object without complaint.

1

If simply restarting e.g., Chrome Canary, with a fresh profile fixes the problem, then one surely is the "victim" of a failed Chrome Variation! Yes, there are ways to opt out of being a Guinea pig in Chrome's field testing.

1

In my case header params can not set null or empty string

{
 'Authorization': Authorization  //Authorization can't use null or ''
}
0
1

In my case, the problem was that Bitdefender provided me with a local ssl certificate, when the website was still without a certificate.

When I disabled Bitdefender and reloaded the page, the actual valid server ssl certificate was loaded, and the ERR_HTTP2_PROTOCOL_ERROR was gone.

1

I experienced the same issue in C# NET Core 6. I was writing results to the body response with the method WriteAsync and returning with Task.CompletedTask

Like below:

await ctx.Response.WriteAsync("something to return");
return Task.CompletedTask;

And changed it to the code below:

 await ctx.Response.WriteAsync("something to return");
 return ctx.Response.CompleteAsync();

And it works fine now.

Apparently, you need to tell the Response object that you finished editing it.

0

I got the same issue (asp, c# - HttpPostedFileBase) when posting a file that was larger than 1MB (even though application doesn't have any limitation for file size), for me the simplification of model class helped. If you got this issue, try to remove some parts of the model, and see if it will help in any way. Sounds strange, but worked for me.

0

I have been experiencing this problem for the last week now as I've been trying to send DELETE requests to my PHP server through AJAX. I recently upgraded my hosting plan where I now have an SSL Certificate on my host which stores the PHP and JS files. Since adding an SSL Certificate I no longer experience this issue. Hoping this helps with this strange error.

0

I also faced this error and I believe there can be multiple reasons behind it. Mine was, ARR was getting timed-out.

In my case, browser was making a request to a reverse proxy site where I have set my redirection rules and that proxy site is eventually requesting the actual site. Now for huge data it was taking more than 2 minutes 5 seconds and Application Request Routing timeout for my server was set to 2 minutes. I fixed this by increasing the ARR timeout by below steps: 1. Go to IIS 2. Click on server name 3. Click on Application Request Routing Cache in the middle pane 4. Click Server Proxy settings in right pane 5. Increase the timeout 6. Click Apply

0
0

My team saw this on a single javascript file we were serving up. Every other file worked fine. We switched from http2 back to http1.1 and then either net::ERR_INCOMPLETE_CHUNKED_ENCODING or ERR_CONTENT_LENGTH_MISMATCH. We ultimately discovered that there was a corporate filter (Trustwave) that was erroneously detecting an "infoleak" (we suspect it detected something in our file/filename that resembled a social security number). Getting corporate to tweak this filter resolved our issues.

0

For my situation this error was caused by having circular references in json sent from the server when using an ORM for parent/child relationships. So the quick and easy solution was

JsonConvert.SerializeObject(myObject, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })

The better solution is to create DTOs that do not contain the references on both sides (parent/child).

0

I had another case that caused an ERR_HTTP2_PROTOCOL_ERROR that hasn't been mentioned here yet. I had created a cross reference in IOC (Unity), where I had class A referencing class B (through a couple of layers), and class B referencing class A. Bad design on my part really. But I created a new interface/class for the method in class A that I was calling from class B, and that cleared it up.

0

In my case (nginx on windows proxying an app while serving static assets on its own) page was showing multiple assets including 14 bigger pictures; those errors were shown for about 5 of those images exactly after 60 seconds; in my case it was a default send_timeout of 60s making those image requests fail; increasing the send_timeout made it work

I am not sure what is causing nginx on windows to serve those files so slow - it is only 11.5MB of resources which takes nginx almost 2 minutes to serve but I guess it is subject for another thread

Not the answer you're looking for? Browse other questions tagged or ask your own question.