Inconsistent ERR_HTTP2_SERVER_REFUSED_STREAM error on page-load Inconsistent ERR_HTTP2_SERVER_REFUSED_STREAM error on page-load wordpress wordpress

Inconsistent ERR_HTTP2_SERVER_REFUSED_STREAM error on page-load


This is not related to WordPress. It's related to either Apache or Nginx using the HTTP/2 standard.

REFUSED_STREAM (0x7): The endpoint refused the stream prior toperforming any application processing (see Section 8.1.4 fordetails).

It can either come from too many concurrent streams:

Endpoints MUST NOT exceed the limit set by their peer. An endpoint that receives a HEADERS frame that causes its advertised concurrent stream limit to be exceeded MUST treat this as a stream error (Section 5.4.2) of type PROTOCOL_ERROR or REFUSED_STREAM. The choice of error code determines whether the endpoint wishes to enable automatic retry (see Section 8.1.4) for details).

It can also be sent during a Push Response operation:

If the client determines, for any reason, that it does not wish to receive the pushed response from the server or if the server takes too long to begin sending the promised response, the client can send a RST_STREAM frame, using either the CANCEL or REFUSED_STREAM code and referencing the pushed stream's identifier.

Or if the client is trying to connect using HTTP/1.1:

Servers that don’t wish to process the HTTP/1.1 response should reject stream 1 with a REFUSED_STREAM error code immediately after sending the connection preface to encourage the client to retry the request over the upgraded HTTP/2 connection.

There is no way for me to pinpoint what is happening during those requests, as it can have multiple reasons, as stated above.

So I suggest you a couple of options:

  • Pass your site's traffic throughugh Cloudflare, so they act as a middle-man for these connections and normalize the requests sent to your server
  • You can increase the SETTINGS_MAX_CONCURRENT_STREAMS to minimize the risk of sending a REFUSED_STREAM. If you use Nginx, you can see how to do this here: http://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_concurrent_streams
  • If you don't know how to do the above, contact your hosting company and ask them to do it for you and upgrade your Nginx version, as some older versions are known to have issues.
  • Disable HTTP/2 in Nginx. How to disable http2 in nginx
  • As a last resource, you can migrate to another hosting company.

If you use Apache, everything I said above applies to it as well.


I do have at least two wordpress sites which very inconsistently throw a varying number of net::ERR_HTTP2_SERVER_REFUSED_STREAM errors. When these errors occur the number of errors thrown highly differs from say 4 requests to about 60 and sometimes even more (if the page has enough requests),

As you said,the count of stream error is more than requests. A possibie explains is stream is push streams which has even stream id. Push stream is initiated by server side. In cotrast, stream initated by client side has odd id.

Why error counts so much?

We follow key error word to try to find some roadmap.search key word ERR_HTTP2_SERVER_REFUSED_STREAM in chromium github repo

We get the following sutuation to reply ERROR_CODE_REFUSED_STREAM.

  • Browser handles server side stream RST frame (SpdySession::OnGoAway).RST frame means closing stream but not closing session.we may recevive error ERR_HTTP2_SERVER_REFUSED_STREAM

  • Browser handles server side stream Goway frame (SpdySession::OnGoAway). Goway frame means closing session. Server side request goway frame without any error(spdy::ERROR_CODE_NO_ERROR).we may recevive error ERR_HTTP2_SERVER_REFUSED_STREAM

The error counts is far more than the requests. So we may be led to stage concultion.
Server side sent RST frame with high probability.

Now we keep digging in.

search key word ERROR_CODE_REFUSED_STREAM in chromium github repo

Server may sent ERROR_CODE_REFUSED_STREAM with the following suituation:

  • When session property enable_push_ is off, but try to create push stream.
  • session state goes to STATE_GOING_AWAY, but receive push stream
  • Wrong Push stream without ":url" header
  • Only http scheme allowed for cross origin push by trusted proxy. If not, get refused.
  • Pushed URL must have https scheme
  • Certificate does not match pushed URL.
  • Duplicate pushed stream with the same url.
  • ERR_TIMED_OUT or ERR_HTTP2_CLIENT_REFUSED_STREAM

Useful utility

use debug tools to get more info.

chrome://net-internals/http2#events

or

chrome://net-export/

About server push news

Chrome to remove server push