'unable to connect to git server via http: HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

For some time now I am not able to use git when remotes are set with a http url. I solved that problem by replacing the http url by corresponding ssh url. However, now I am stuck because I want to install homebrew and the install script attempts to call github through an http address. I get the following error:

==> Downloading and installing Homebrew...
fatal: unable to access 'https://github.com/Homebrew/brew/': HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
Failed during: git fetch --force origin

Unfortunately, the internet didn't provide me a solution. The only thing I could find so far was something similar about a git push problem with suggested solutions to increase git's buffersize, change the http version to 1.1 or change the internet network. Neither of these options works for me.

Any ideas why I get that error or how to troubleshoot it? Thanks in advance

os: macOS monterey v12.1 tried it out with git versions v2.29.3, v2.32.0 and v2.34.1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source