Solution to Alibaba Cloud Server Failure to Access GitHub.com

How to access GitHub on Alibaba Cloud Server

(Domestic area) is a common problem, usually associated with,orThe following is an analysis and solution to this problem, which is applicable to most cases:

Solution to Alibaba Cloud Server Failure to Access GitHub.com

Cause

Network restrictions:

The network environment in mainland China has access restrictions on some overseas websites (such as GitHub), which may be caused by operators or firewalls.

Alibaba Cloud domestic servers are affected by these restrictions, especially unregistered domain names or IPs.

DNS resolution failed:

The default DNS server may not correctly resolve the IP address of GitHub.com, causing Could not resolve host: github.com mistake.

:

GitHub uses (port 443) or (Port 22) may be used by Alibaba CloudOr blocked by server firewall.

Server configuration issues:

Local network configuration (such as )orThe setting may cause access exceptions.

Solution

Method 1: Modify DNS configuration

View the current DNS configuration

cat /etc/resolv.conf

If the default DNS (such as 100.100.100.100 provided by Alibaba Cloud) cannot resolve GitHub, replace it with a public DNS:

Google DNS: 8.8.8.8 and 8.8.4.4
DNS: 1.1.1.1 and 1.0.0.1

Edit /etc/resolv.conf

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf echo "nameserver 1.1.1.1" | sudo tee -a /etc/resolv.conf

Test access to see if ping is successful

ping github.com

If the above method doesn't work and you still can't access GitHub, then the problem should be with the website domain name resolution.

Method 2: Manually add hosts file

Get GitHub's IP address:
Run locally (in an environment without network restrictions):

ping github.com

Solution to Alibaba Cloud Server Failure to Access GitHub.com

This gets the latest IP address of github.com. Of course, you can also ping github.com on different servers to get some different addresses.

Solution to Alibaba Cloud Server Failure to Access GitHub.com

 

  • 20.205.243.166
  • 140.82.114.3
  • 140.82.112.3
  • 140.82.113.3
Or visit ipaddress.com Query GitHub's IP
Solution to Alibaba Cloud Server Failure to Access GitHub.com
Edit Server /etc/hosts document:
sudo vi /etc/hosts

Solution to Alibaba Cloud Server Failure to Access GitHub.com

After editing, save and exit! Ping again

Solution to Alibaba Cloud Server Failure to Access GitHub.com

The IP address you just filled in has been successful! Now the server can access GitHub.

GitHub uses multiple IPs, which may change due to load balancing and need to be updated regularly.
Suitable for temporary solutions, cannot handle all GitHub related domains (such as raw.githubusercontent.com).

The simplest and quickest solution isModify DNSorAdd hosts
5/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *