1
php
protocol_error
ai_generated
true
GuzzleHttp\Exception\ConnectException: cURL error 1: Protocol "http2" not supported or disabled in libcurl (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /var/www/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187
ID: php/guzzle-http-version-not-supported
85%Fix Rate
85%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Guzzle 7.0 | active | — | — | — |
| Guzzle 7.5 | active | — | — | — |
| PHP 8.1 | active | — | — | — |
| PHP 8.2 | active | — | — | — |
Root Cause
The installed libcurl version does not support HTTP/2, but the Guzzle client is configured to use 'http2' as the protocol version.
generic中文
安装的 libcurl 版本不支持 HTTP/2,但 Guzzle 客户端被配置为使用 'http2' 作为协议版本。
Official Documentation
https://docs.guzzlephp.org/en/stable/request-options.html#versionWorkarounds
-
90% success Downgrade the Guzzle client to use HTTP/1.1 instead: `$client = new GuzzleHttp\Client(['version' => '1.1']);`
Downgrade the Guzzle client to use HTTP/1.1 instead: `$client = new GuzzleHttp\Client(['version' => '1.1']);`
-
75% success Upgrade libcurl to a version that supports HTTP/2. On Ubuntu/Debian: `sudo apt-get update && sudo apt-get install --only-upgrade libcurl4-openssl-dev` and then recompile PHP's cURL extension. Verify with `php -i | grep cURL` and check 'cURL Information' for HTTP2 support.
Upgrade libcurl to a version that supports HTTP/2. On Ubuntu/Debian: `sudo apt-get update && sudo apt-get install --only-upgrade libcurl4-openssl-dev` and then recompile PHP's cURL extension. Verify with `php -i | grep cURL` and check 'cURL Information' for HTTP2 support.
中文步骤
Downgrade the Guzzle client to use HTTP/1.1 instead: `$client = new GuzzleHttp\Client(['version' => '1.1']);`
Upgrade libcurl to a version that supports HTTP/2. On Ubuntu/Debian: `sudo apt-get update && sudo apt-get install --only-upgrade libcurl4-openssl-dev` and then recompile PHP's cURL extension. Verify with `php -i | grep cURL` and check 'cURL Information' for HTTP2 support.
Dead Ends
Common approaches that don't work:
-
Setting CURLOPT_HTTP_VERSION to CURL_HTTP_VERSION_2_0 manually in a custom handler
95% fail
This does not fix the underlying libcurl limitation; it just changes the constant used, but libcurl still cannot negotiate HTTP/2.
-
Reinstalling PHP and cURL extension via apt-get without checking the libcurl version
70% fail
The default system libcurl on older OS versions may still lack HTTP/2 support; you need to ensure the libcurl-dev package is from a version that supports HTTP/2 (e.g., >= 7.50.0).