Mac 终端 Git 问题解决:Failed to connect to github.com port 443: Operation timed out

终端拉取github代码的时候提示

Failed to connect to github.com port 443: Operation timed out

解决方案(mac为例):

1. 打开https://github.com.ipaddress.com/ 如下图:
image.png

把IP Address 记录下来!

2.打开https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo 如下图:
image.png

把IP Address 记录下来!

3.打开https://github.com.ipaddress.com/assets-cdn.github.com 如下图:
image.png

把IP Address 记录下来!

4.打开电脑的hosts文件,把下列的东东写在最后,然后保存即可

终端输入,需要权限,要输入密码

sudo vim /etc/hosts

将刚才复制的 IP Address 写入hosts文件中

140.82.113.4(图1的IP Address) github.com 
199.232.69.194(图2的IP Address) github.global.ssl.fastly.net
185.199.108.153(图3的IP Address)  assets-cdn.github.com
185.199.109.153(图3的IP Address)  assets-cdn.github.com
185.199.110.153(图3的IP Address)  assets-cdn.github.com
185.199.111.153(图3的IP Address)  assets-cdn.github.com
效果图如下:
hosts文件

编辑完成后,按 esc ,输入 :wq ,按 enter,保存并退出

5.在终端在输以下指令刷新DNS
sudo killall -HUP mDNSResponder;say DNS cache has been flushed
6.再去使用git命令试试吧
git clone     
git install
git pull
git push
。。。

你可能感兴趣的:(Mac 终端 Git 问题解决:Failed to connect to github.com port 443: Operation timed out)