0%

Solutions to github cannot be opened or slow to load

Solutions to github cannot be opened or slow to load

Foreword

GitHub is a hosting platform for open source and private software projects, because it only supports Git as the only repository format for hosting, hence the name GitHub.
As an open source code library and version control system, Github has more than 9 million developer users. As more and more applications move to the cloud, Github has become the preferred method for managing software development and discovering existing code.
Recently I wanted to tinker with it, but I found a problem and I can’t access the GitHub website at all (Is my thoughts about to be pinched out as soon as they sprout?), that’s right, the picture below

This was so anxious for me, so I immediately asked Baidu for help. I also assembled many tutorials (trying the methods of various great gods), and finally solved the problem. (Pay attention to check if you are surfing the Internet scientifically, this will also lead to inaccessibility)

Here is a solution (useful for pro-testing)

One: Modify the hosts file

windows

  1. Find the hosts file
    The path is: C:\Windows\System32\drivers\etc\hosts
  2. Edit the file
    You can open it with Notepad and copy the text below.
192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
151.101.100.133 cloud.githubusercontent.com
151.101.100.133 camo.githubusercontent.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 avatars2.githubusercontent.com
151.101.100.133 avatars3.githubusercontent.com
151.101.100.133 avatars4.githubusercontent.com
151.101.100.133 avatars5.githubusercontent.com
151.101.100.133 avatars6.githubusercontent.com
151.101.100.133 avatars7.githubusercontent.com
151.101.100.133 avatars8.githubusercontent.com
  1. Save (try again if you can open GitHub)

Linux

  1. Also find the hosts file
    But the path becomes: /etc/hosts
  2. Edit the hosts file
    Also copy the following code block (same as above) and save
192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
151.101.100.133 cloud.githubusercontent.com
151.101.100.133 camo.githubusercontent.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 avatars2.githubusercontent.com
151.101.100.133 avatars3.githubusercontent.com
151.101.100.133 avatars4.githubusercontent.com
151.101.100.133 avatars5.githubusercontent.com
151.101.100.133 avatars6.githubusercontent.com
151.101.100.133 avatars7.githubusercontent.com
151.101.100.133 avatars8.githubusercontent.com
  1. Generally, the permissions are not enough for modification, and you need to obtain root permissions. Of course, temporary root permissions are also OK.
    Enter vim /etc/hosts to modify

Use the above content to solve the problem, check the relevant IP by yourself

The following demonstrates the IP query methods of several nodes, and the others find themselves

First determine the IP of GitHub
turn on

Link


You can see that the IP address is: 140.82.114.4 (according to personal circumstances)
Determine the IP of the domain name:
turn on
Link

IP is 192.232.69.194
Determine the IP of the static resource:
turn on
Link

According to the above method 1 or method 2, query the contents of the hosts one by one, and write the hosts file
Add as follows (written according to personal circumstances, the following is mine)

140.82.114.4 github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.108.153 github.github.io
185.199.109.153 github.github.io
185.199.110.153 github.github.io
185.199.111.153 github.github.io
185.199.108.153 avatars0.githubusercontent.com
185.199.108.153 avatars1.githubusercontent.com
185.199.108.153 avatars2.githubusercontent.com
185.199.108.153 avatars3.githubusercontent.com
185.199.108.153 avatars4.githubusercontent.com
185.199.108.153 avatars5.githubusercontent.com
185.199.108.153 avatars6.githubusercontent.com
185.199.108.153 avatars7.githubusercontent.com
185.199.108.153 avatars8.githubusercontent.com

Two: Modify DNS resolution

  1. Right-click on the network icon

  1. Click to open the “Network and Internet” settings

  1. Pull down to find the Network and Sharing Center, click to enter

  1. Click the red box to select the part

  1. Click Properties

  1. Select Internet Protocol version 4, click Properties

  1. Choose to use the DNS server address below and enter the DNS address

  1. Here I recommend two 4.2.2.2 (Microsoft) and 223.5.5.5 (Ali), then click OK

Three: Refresh the DNS resolution cache

After changing the hosts file, it is recommended to refresh the DNS cache

1.win+R open the run window, enter cmd, click OK to open the cmd window

  1. Enter the following command and press Enter
ipconfig /flushdns

Four: github mirror access

Two github mirror sites are provided here, in case of unexpected events

https://github.com.cnpmjs.org

https://hub.fastgit.org

Five: New

Add one

  1. Open the DNS query tool (this is a tool for querying the mapping of domain names)

Click to go

  1. Enter github.com and click detect

You can also check the following URL (I checked the github official website), and then follow the steps below

github.global.ssl.fastly.net
assets-cdn.github.com
  1. Find the smallest TTL value in the query result and copy its ip

  1. Write the hosts file, save it, and how to write it has been mentioned before, so I won’t repeat it

image-20210307164826147

Add two

It’s very tiring to query the ip by yourself, I also found a lot of automatic query projects on github, friends can go and see

Github520

Python automatic query ip

GithubHighSpeed

If you don’t understand the specific eating method, you can ask me (personally recommend the first one)

Remarks

This article only records how I solved the problem of inaccessibility to GitHub

It is recommended to find the IP by yourself, failure is normal

-------------The end of this articleThank you for your reading-------------