[Fixed] Failed to connect to raw.githubusercontent.com port 443: Connection refused


How to fix the annoying error Failed to connect to raw.githubusercontent.com port 443: Connection refused while downloading files from GitHub.

You may encounter the following error when downloading a file via a terminal or command line from GitHub using wget or some other utility. Or downloading NTLK or any library via Python from GitHub.

wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
--2022-12-28 13:02:52-- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)… 49.44.79.236, 2405:200:1607:2820:41::36
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|49.44.79.236|:443… failed: Connection timed out.
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2405:200:1607:2820:41::36|:443… failed: Network is unreachable.

The main reason for this error varies, as you can see. It’s related to the SSL connection from your local network in your laptop/desktop to the GitHub server. If you are facing this error from your company’s network, it might be related to the proxy setup in the git config file.

Unfortunately, you may get this error even if you are not using any proxy and connecting to GitHub from your personal laptop.

If you are in India and using the Jio network, you may face this as well because the ISP blocks the raw.githubusercontent.com at the DNS level for some unknown reason!

Failed to connect to raw.githubusercontent.com port 443 error

There are many ways to fix this. Try any one of the following to solve it.

Fixing Error: Failed to connect to raw.githubusercontent.com port 443

Fix 1: Updating the /etc/hosts file in Linux & Windows

If you are getting this error in Ubuntu or any other Linux distribution, then you can add the following GitHub domain IPv4 addresses to resolve this.

Open the /etc/hosts file via nano or any editor. This is the same path for macOS as well.

sudo nano /etc/hosts

For Windows, open the host file in this path: %SystemRoot%\System32\drivers\etc\hosts

C:\System32\drivers\etc\hosts

Open this file via Notepad in Windows with Admin privileges (Start > Notepad icon > right-click > More > Open as administrator).

Then, at the end of this file, add the IP address and the domain name. Same for both Linux & Windows.

185.199.110.133 raw.githubusercontent.com
Updating host file

Save and close the file. Restart your Linux/macOS/Windows or restart your network.

And try to download it from GitHub again, and it should work. If not, try the next steps.

Fix 2: Change DNS

If the above steps do not work, try changing the DNS of your system by adding Google’s global DNS server so that the URL is properly translated.

For example, in Linux Mint, you can open Network from the application menu. Click on the small gear icon beside your active network or WiFi.

Disable automatic DNS.

Add the below two IP addresses for the custom DNS server under IPv4:

8.8.8.8
1.1.1.1

Apply and restart your system. And you should be all set.

Add DNS in macOS
Changing DNS in Linux Mint
Changing DNS in GNOME
DNS update in Windows

Fix 3: Reset the proxy config

If you have a local git setup with ~/.gitconfig in your home directory, you may run the following command to reset the proxy settings.

git --global --unset http.proxy
git --global --unset https.proxy

Then, restart your system. And try to see whether the error goes away.

Fix 4: Force reset the proxy to an empty string

You can also try the following command to set the proxy to an empty string. And then verify.

git config --global http.proxy ""

Fix 5: Update the proxy settings with your network details

If you are getting this error from your corporate network with a private repo, you might need to ask your network admin for the username and password with GitHub proxy details. Once you have that, run the following from the terminal. Replace the username, password, address, and port in the command below. Also, if your user name contains ‘@’ character, encode it to ‘%40’.

git config --global http.proxy http[s]://userName:password@proxyaddress:port

Wrapping Up

I hope you can resolve this error using any of the above methods.

Please let me know which of the above methods works in the comment box.

References: [1], [2]

Exit mobile version