Several weeks ago, I found out that I could github
n't display pictures when opening the webpage, but I didn't care about it at the time.
Today, the obsessive-compulsive disorder forced me to fix it, so I went to find some methods and made a record by myself. Partners with the same problem can refer to it.
problem
For example, I just open a project, the picture can't be displayed, and my avatar is gone. It's a sad thing. F12
Open the console and look at it. A
bunch of red ×s. The main error isFailed to load resource: net::ERR_CERT_COMMON_NAME_INVALID
I checked it, blogger john-zeng explained:
In fact, it can be considered that
ERR_CERT_COMMON_NAME_INVALID
thehttps
resource of a certain node is accessed with a wrong domain name . The reasons for this error are basically:
- dns pollution
- host setting error
- The dns was officially updated, but the dns cache was not updated, resulting in incorrect resolution.
I think it seems a bit reasonable, the solution is rough, hin is simple, look down.
Solution
The main idea is to use local hosts
files to resolve the domain name of the website. General DNS
problems can be solved by modifying the hosts
file. The problem github
of CDN
contaminated domain name is no exception. It can also be solved by modifying the hosts
file. The domain name resolution can be directly pointed to the IP
address to bypass DNS
the resolution. , In order to solve the pollution problem.
Find URL
Open github
any webpage that does not display pictures, use the element selector ( Ctrl+Shift+C
) to place on the picture that cannot be displayed, or right-click on the picture that cannot be displayed-check the element, locate the label of the picture, then you get its URL, called src
Attributes.
For example,
please copy its URL on the right:
https://avatars2.githubusercontent.com/u/15832957?s=60&v=4
Get IP address
After obtaining the URL to open IPAddress.com this website, enter its domain name in the search box, that is, https://
to com
that part, commonly known as second-level domain:
avatars2.githubusercontent.com
Enter! ! ! Below you will see a message and the domain name IP
address:
we can see IP is: 151.101.184.133
and is 2019.05.05 last updated, alright, then we can make this IP and domain name mapping them.
(If there are other hanging pictures, use this method for one-to-one mapping.)
Modify hosts
How to map specifically? Modify the hosts
file! ! ! I am using the windows
system, so use to Sublime Text
open:C:\Windows\System32\drivers\etc\hosts
Add at the end of the file:
You can directly select the following content to copy and paste, update 20200328
# GitHub Start
140.82.113.3 github.com
140.82.114.20 gist.github.com
151.101.184.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com
# GitHub End
Then save the file and it is OK. As for the file cannot be saved, there is no modification authority, right click the mouse-Properties-Security-Modify authority; or hosts
copy the file, after modification, copy to the original folder and replace!
A few last words
You can also use ipconfig/flush
to refresh the local DNS cache. If you encounter a network abnormality, it may be a problem with the DNS cache. Refresh, step by step.
- windows start→run→input: CMD Press Enter to open the command prompt window.
- Then enter: ipconfig /flushdns Press Enter, execute the command, you can rebuild the local DNS cache.
Attach a few more commands:
ipconfig /displaydns # 显示dns缓存
ipconfig /flushdns # 刷新DNS记录
ipconfig /renew # 重请从DHCP服务器获得IP
PS: Another thing to note is that if the picture cannot be displayed again, you only need to update the IP in time. This wave of operation is not troublesome, you see my profile picture is back! ! !