189

There are a lot of topics about the HTTP/2 protocol, but I wonder if there is a working website with this protocol.

I.e.

We can decide to use http:// or https://, but how can we write a HTTP/2 request?

I am aware that this protocol depends on the server capability, but I can not find a way to check if a website, e.g. google.com, has HTTP/2 support enabled.

HTTP/2 browser support

As I can see in this picture, all modern browsers support this protocol. I have not seen any link that could look like a new generation protocol.

Are we using the HTTP/2 protocol without knowing or it is just a fairy tale?

2
  • 4
    It's not your decision to make. Protocol version depends upon remote server compatibility. http2:// would not make any sense, because it's still the same http protocol, just another version. Having one http:// uri makes fallback possible, so if possible version 2 is used, otherwise fallback to v1.
    – Mike Doe
    Commented Jan 8, 2019 at 12:13
  • 2
    @emix But wouldn't it make sense to prepend http2:// if its available? And prepend https:// if its not. I mean using this theory there would be no reason to prepend https:// right? Not trying to be a smart guy, I am just curious.
    – SHINIGAMI
    Commented Aug 1, 2021 at 17:14

10 Answers 10

320

You can just check it in: Chrome Dev Tool (F12) → NetworkProtocol.

It will tell you the protocol used and the domain of each transfer.

Chrome Dev Tool (F12) -> Network -> Protocol

Legend

http/1.1 = HTTP/1.1
h2          = HTTP/2
h3          = HTTP/3


Note: If you cannot see the Protocol column, just right-click on any header and check the "Protocol" label.

3
  • 75
    I had to right-click on the headers and add "Protocol" as a visible header. TIL that there are more columns that can be added in Chrome Dev Tool > Network.
    – rinogo
    Commented Sep 27, 2019 at 22:03
  • 3
    Had to right-click on the Name header the other columns were not right clickable. 👍 Commented Mar 26, 2021 at 15:02
  • 1
    Mine is a bit special, no matter what is checked, the only column I see is name. Any ideas? I also found that protocol is visible if I click on "View source" in Response Headers section.
    – lovrodoe
    Commented Nov 25, 2021 at 15:16
82

You can use the curl command to find out if a particular website has HTTP/2 protocol support or not. In the following example, just replace https://www.cloudflare.com/ with the URL you want to check for HTTP/2 support:

% curl -vso /dev/null https://www.cloudflare.com/ 2>&1 | grep ALPN

If you see output like:

* ALPN: offers h2,http/1.1
* ALPN: server accepted h2

offers h2,http/1.1 means the website has HTTP/2 protocol support.

server accepted h2 means you are using HTTP/2.

ALPN is the TLS extension that HTTP/2 is expected to use.

Please also note that:

When curl uses HTTP/2 over HTTPS, it does not itself insist on TLS 1.2 or higher even though that is required by the specification. A user can add this version requirement with --tlsv1.2.

You can also use --http2-prior-knowledge or, --http2.

5
  • 2
    On my terminal the lines were lost among huge numbers of unknown TLS. curl -vso /dev/null --http2 https://www.cloudflare.com/ 2>&1| grep "offering h2"
    – Programmer
    Commented Dec 8, 2020 at 15:43
  • Thanks, @blueray. YOu save my days. I just want to understand the meaning of '-vso' keyword. I tried on Google but did not get anything. Commented Jun 14, 2021 at 4:25
  • 2
    Running curl against any https url will, by default, try to establish an http2 connection. From what I can gather, "...offering h2" is an indication that the client, not the server, is willing to use http2. Running curl -vso /dev/null --http2 https://site.i.know.does.not.support.http2 always returns "offering h2". I have found running curl -sI https://site.i.want.to.test -o /dev/null -w '%{http_version}\n' to more reliably indicate http2 support.
    – terryf82
    Commented Aug 24, 2021 at 21:03
  • @terryf82 please check HTTP/2 with curl and TLS in HTTP/2. My answer is to check "if a website has HTTP/2 protocol support". Your command is to figure out "The http version that was effectively used". Commented Aug 31, 2021 at 4:21
  • "ALPN, offering *" is from the client (client added these to ALPN request). you'd see the same output if server does not support h2. The response from the server is printed afterwards. for eg: Server does not support h2. * ALPN, offering h2 * ALPN, offering http/1.1 … * ALPN, server did not agree to a protocol h2 supported server: * ALPN, offering h2 * ALPN, offering http/1.1 … ALPN, server accepted to use h2
    – Najmuddin
    Commented Mar 11, 2022 at 22:35
41

HTTP/2 reuses the http:// and https:// schemes rather than use new ones.

All browsers only support HTTP/2 over https:// and part of the SSL/TLS negotiation is to communicate whether both sides support HTTP/2 and are willing to use it (using an extension to SSL/TLS called ALPN).

The advantage for this is you can just connect to a website and if your browser supports it, it will automatically negotiate HTTP/2, and if not it will automatically fall back to HTTP/1.1.

So to test for HTTP/2 support you can use the browser as Markus's suggests (make sure to add the Protocol column to the Network tab in Chrome for example).

Or you can use an online tester like https://tools.keycdn.com/http2-test

Or you can use a command line tool like openssl (assuming it's been built with ALPN support): openssl s_client -alpn h2 -connect www.example.com:443 -status.

Most of the larger websites (e.g. Twitter, Facebook, Amazon, Stack Overflow) are using HTTP/2 now.

5
  • You mentioned browser can start with HTTP/2 and can switch back to HTTP/1.1 if server does not support HTTP/2. How about if client does not support HTTP/2. Can a single server serve both HTTP/1.1 and HTTP/2. I am looking to support both versions with a single tomcat instance.
    – Bagira
    Commented Jul 5, 2020 at 3:08
  • 2
    It’s not so much it starts with HTTP/2 and switches back. What happens is the browsers opens the HTTPS connection and says “I support this version of TLS, these ciphers, and HTTP/2 - let me know which of those works for you” and then the server decides the best settings to use that they both understand. If browser has said it supports HTTP/2 and server does too then it’ll use that. If browser hasn’t said it’ll support it, but server does then it’ll use HTTP/1.1. And if browser says it supports it and server is like “what is this HTTP/2 you speak of?” then it’ll ignore it and use HTTP/1.1. Commented Jul 5, 2020 at 7:37
  • So yes a server should support both instances and use what’s appropriate. We are far, far away from an HTTP/2-only world and will be dealing with HTTP/1.1 for some connections for a long, long time. Commented Jul 5, 2020 at 7:38
  • Thanks I understand the points which you mentioned. My question is still the same, Can we support both HTTP/2 and HTTP/1.1 with single server. For tomcat it is suggested that make changes in server.xml to use HTTP/2. If do that, can that tomcat instance handle HTTP/1.1 traffic because I heard HTTP/2 is not backwards compatible.
    – Bagira
    Commented Jul 5, 2020 at 17:34
  • 2
    Don't use Tomcat myself, and the docs aren't exactly clear on this from a quick Google, but I'd be very surprised if adding HTTP/2 support disabled HTTP/1.1 support. Commented Jul 5, 2020 at 22:28
37

Open Dev Tools in Chrome using F12. Then go to the Network tab.

Right click on a row, select Header Options, and then select Protocol from the menu.

Enter image description here

2
  • What protocol is "h3"? Commented Jul 20, 2021 at 5:10
  • 2
    @oᴉɹǝɥɔ HTTP/3 Commented Jan 25, 2022 at 23:32
17

This question has been answered already but I am going to answer this still.

Go to Chrome's Developer Tools. You can open up the Developer tools in many ways like:

  • I am on Mac so I use ⌥⌘i (⌥+⌘+i)combination to open up the dev tools on the Chrome browser. It does select the Network tab by default if you use the keyboard combination.
  • You can use alternatively F12 on your keyboard to do the same.
  • You can open up Developer Tools just by clicking the three dots, also known as ellipsis, shown on the top right corner of your browser. Click on Three dots aka ellipsis -> More Tools -> Developer Tools

In the Name column right-click and make sure Protocol is checked. Now you can see the Protocol Column where h2 refers to HTTP/2 and h3 refers to HTTP/3 in case you see them and http/1.1 refers to HTTP/1.1.

enter image description here

enter image description here

You can see the Protocol Column alternatively the following way:

  • Right-click the row that you see under the Name column and the click on Header Options and check Protocol. enter image description here enter image description here

  • You can also check from here for free. An example is here: type in there https://google.com or your site with HTTPS protocol.

  • There is also a chrome browser extension that can help you. The ref link is here.

  • You can also use curl command to check. This thread has an accepted answer for this.

  • You can use this command if you like CLI

    curl -sI --http2 https://stackoverflow.com/ | grep -i "HTTP/2"

7

Open the browser development tools and switch to the network tab. There you'll see h2 if HTTP/2 is available.

1
  • 3
    I could not find in 3 minutes, can u share screenshot plz
    – Sami
    Commented Oct 2, 2021 at 6:21
7

Solution using curl command as the existing curl solution did not work well for me. curl provides a switch --http2-prior-knowledge which ensures a direct HTTP/2 request is sent without attempting a HTTP/1.1 upgrade request. Below examples can help understand the behavior in different cases:

Curl to Google which supports HTTP/2 - automatically HTTP/2 is chosen.

curl -Iks https://www.google.com/robots.txt

HTTP/2 200 
accept-ranges: bytes
vary: Accept-Encoding
content-type: text/plain
content-length: 7199
cross-origin-resource-policy: cross-origin
date: Fri, 21 May 2021 13:39:02 GMT
expires: Fri, 21 May 2021 13:39:02 GMT
cache-control: private, max-age=0

Curl to my server which does not supports HTTP/2 - response states HTTP/1.1

curl -Iks https://myserver/reset
HTTP/1.1 502 Bad Gateway
connection: close
content-length: 0

Curl to my server with --http2 switch. Response still states HTTP/1.1

curl -Iks --http2 https://myserver/reset
HTTP/1.1 502 Bad Gateway
connection: close
content-length: 0

Curl to my server with --http2-prior-knowledge. Note that no response is obtained.

curl -Iks --http2-prior-knowledge https://myserver/reset

If the above is executed with v switch (verbose), the output would include the below line.

* http2 error: Remote peer returned unexpected data while we expected SETTINGS frame.  Perhaps, peer does not support HTTP/2 properly.

Note:

  • Switch k is for insecure - my server uses a self signed certificate. Not needed otherwise.
  • Switch I is to send a HEAD request and avoid noise in output.
  • Above is captured with curl 7.58.0 on Ubuntu 18.04
1
  • Good answer with explanation and the only answer which I could get to work and see things.
    – Raymond
    Commented Mar 20, 2022 at 17:37
5

You can use command

curl -vso /dev/null https://google.com 2>&1 | grep ALPN

The output is going to be either

 * ALPN, offering h2 // Client is offering HTTP 2 protocol
 * ALPN, offering http/1.1 // Client is also offering HTTP 1.1 protocol
 * ALPN, server accepted to use h2 // Server said that it is going to use HTTP 2 protocol

Or

* ALPN, offering h2 // Client is offering HTTP 2 protocol
* ALPN, offering http/1.1 // Client is also offering HTTP 1.1 protocol
* ALPN, server accepted to use http/1.1 // Server said that it's going to use HTTP 1.1 protocol, even though client supports HTTP 2.0

You can see explanations are right in the quoted output after //

4

You can also use a cool Chrome/Firefox extension called HTTP/2 and SPDY indicator to check the website protocol.

-1
curl -I --http2 -s https://domain.url/ | grep HTTP
2
  • 2
    It helps more if you supply an explanation why this is the preferred solution and explain how it works. We want to educate, not just provide code. Commented Sep 30, 2021 at 19:55
  • On some sites, this outputs HTTP/2 200, on some others, HTTP/1.1 200 OK. Do you mean to recommend parsing the output of this command?
    – joanis
    Commented Oct 1, 2021 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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