'getting curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number every time I run brew

Title. I've been unable to run brew due to this error. I'm not currently running any proxies or any other things that would disrupt online connection. When I run it in verbose, it prints this.

/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.0.2\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 11.2.1\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --range 0-1 --dump-header - --write-out \%\{http_code\} --output /dev/null https://homebrew.bintray.com/bottles/xorgproto-2021.3.big_sur.bottle.tar.gz
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.0.2\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 11.2.1\)\ curl/7.64.1 --header Accept-Language:\ en --fail --retry 3 --location --remote-time --continue-at 0 --output /Users/cameron/Library/Caches/Homebrew/downloads/4a01df4ef68ab52d11137a08c3675ac23d552925e4e667998e6d88ce18918d5d--xorgproto-2021.3.big_sur.bottle.tar.gz.incomplete https://homebrew.bintray.com/bottles/xorgproto-2021.3.big_sur.bottle.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number


Solution 1:[1]

This is an issue with their CDN.

See here: https://github.com/Homebrew/brew/issues/10739

A workaround would be adding this to your hosts file:

54.188.157.32 homebrew.bintray.com

Solution 2:[2]

If you are just using curl for a post request, check that you are not using https instead of http.

Solution 3:[3]

It looks like there is currently a misconfiguration of the server or it is the wrong server to use. The server is not able to do any TLS handshake on port 443, no matter which client is used. From SSLLabs:

enter image description here

Solution 4:[4]

If you do not have permissions to modify your hosts file, you can also try this workaround:

~> HOMEBREW_BOTTLE_DOMAIN=https://dl.bintray.com/homebrew brew upgrade

to run the brew upgrade command while setting the HOMEBREW_BOTTLE_DOMAIN environment variable temporarily. It has solved my problem when upgrading my Brew packages.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Souljacker
Solution 2 B.Anas
Solution 3 Steffen Ullrich
Solution 4 Arda Aytekin