'Homebrew installation on Mac OS X Failed to connect to raw.githubusercontent.com port 443

When I try to install Homebrew, I am getting following connection refused error. Please help me to solve this problem.

$ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused


Solution 1:[1]

The accepted Answer is outdated now. But based on the answer I solved the problem by:

  1. open the home page of brew https://brew.sh/
  2. copy the URL from the install cmd and open it on your browser https://raw.githubusercontent.com/Homebrew/install/master/install.sh
  3. right-click and save it to your computer
  4. open a terminal and run it with: /bin/bash path-to/install.sh

Solution 2:[2]

It was a company proxy problem for me and the solution as mentioned here worked for me.

export HTTPS_PROXY=https://<proxy.mycompany>:<port>

git config --global https.proxy $HTTPS_PROXY

git config --global --get https.proxy

Solution 3:[3]

I had the same error,

- Disabled VPN

tried again installing without VPN It worked for me.

Solution 4:[4]

I've seen this a few times on other people's machines and it seems to be fixed after you install xcode, i.e. xcode-select --install

Solution 5:[5]

There are several situations here, you can do following things :

  1. reinstall the xcode command line tool by removing the old tools ($ rm -rf /Library/Developer/CommandLineTools) and xcode-select --install
  2. request web page https://raw.githubusercontent.com/Homebrew/install/master/install then save it's content to shell file then run it.
  3. change your DNS server to 8.8.8.8 (This is worked for me : ] )

Finally you should run /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Solution 6:[6]

These steps solved the problem:

  1. xcode-select --install
  2. restart the Mac
  3. Execute this command:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

and it should work.

Solution 7:[7]

Check is https proxy is set

env|grep -I proxy

Then if it is set, remove the env variable

unset HTTPS_PROXY

Solution 8:[8]

~ % cd /ect/
~ % vim host
199.232.68.133 raw.githubusercontent.com

Solution 9:[9]

I solved this problem by the following steps:

  1. removing the old tools ($ rm -rf /Library/Developer/CommandLineTools)
  2. install xcode command line tools again ($ xcode-select --install).

Solution 10:[10]

Although saving the shell file locally and then running it can solve this problem, but you'll meet it again when you do something similar(e.g. install oh-my-zsh, vim-plug, etc.)

At last, I find the 3rd item of this answer(https://stackoverflow.com/a/61787208/5458745) works best for me, as it can also solve the problem I meet when installing other tools using curl. However instead of changing the DNS, I add 8.8.8.8 to my original DNS server list, which works fine for me.

Change your DNS server to 8.8.8.8 (This is worked for me)

Solution 11:[11]

I solved it.

You can visit https://github.com/Homebrew/install/blob/master/install.sh to get this install.sh by copy the whole contents.

Then paste it into install.sh and run sh install.sh.

Solution 12:[12]

A combination of what @blueskin mentioned first and then what @Ferenc Yim mentioned is what worked for me.

The script also requires sudo access (not necessarily run with a sudo prefix just need admin access)

Solution 13:[13]

If you are behind a proxy, try this:

sudo vim /etc/hosts

#add the line below and :wq

199.232.28.133 raw.githubusercontent.com

Solution 14:[14]

The method of using ruby is probably outdated, as shown below:

Error logs

As a better alternative, please set your computer's DNS server to 8.8.8.8

Setting DNS

working