Solve the error of git clone in Ubuntu18.04 Failed to connect to github.com port 443: Connection refused

(If you only want to see the solution, you can scroll directly to the end of the article!!!)

The first time I used git clone in the ubuntu terminal, the error message was Failed to connect to github.com port 443: Connection refused. After struggling for a long time, I finally downloaded it successfully (thanks to this blog for the rescueWhat should I do if Failed to connect to github.com port 443: connection timed out during git clone - CSDN Blog)

First paste the terminal operation

I tried several times but got the error Failed to connect to github.com port 443: Connection refused.

Turning off git's SSL certificate verification can also be understood as canceling the security verification of the remote warehouse. Can't be solved.

(Furthermore, turning off SSL certificate verification will reduce the security of data transmission, so you should try to avoid using this command in a highly secure environment. At the same time, when necessary, it is recommended to use a proxy or other security measures to ensure the safety of data transmission. Safety.)

Many people on the Internet talk about this method: setting a global proxy. It may be that my proxy address is not set properly, but it is not solved anyway. If not, remember to cancel the global proxy

I changed https to git as mentioned online, but it still doesn’t work.


Final solution: modify the hosts file

1) Open https://github.com.ipaddress.com/ 

Scroll down to find DNS Resource Records and remember the IP address below

2) Open https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo

Scroll down to find DNS Resource Records and remember the 4 addresses below

3) Open the hosts file

Open a new terminal and entersudo gedit /etc/hosts, you will be prompted to enter the user password, and you can open the file after entering it a>

4) Modify hosts file

Add the following content at the end of the hosts file and save:

140.82.112.3 github.com
151.101.1.6 github.global.ssl.fastly.net
151.101.65.6 github.global.ssl.fastly.net
151.101.129.6 github.global.ssl.fastly.net
151.101.193.6 github.global.ssl.fastly.net

5) Re-enter in the original terminalgit clone https://github.com/DroidAITech/ROS-Academy-for-Beginners.git (change to your own github project Address)

Download started successfully! ! !

Guess you like

Origin blog.csdn.net/weixin_42149550/article/details/133682119