今天在Github上新建了一个项目,用来写demo,pod install 的时候一直失败,情况如下:
Failed to connect to github.com port 443: Timed out
结果:显示为github链接超时
总体解决思路如下:先去终端ping一下github,是否为真的超时?如果真的超时,就去修改替换github ip,如果不是再去考虑git的配置问题。
打开终端,尝试命令:ping github.com 情况如下:
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
结果:真的是github ping不上。
解决思路:去寻找能ping上 github对应的ip,寻找ip的地址是这个:https://tools.ipip.net/dns.php 进去后,搜寻github网站对应的ip,情况如下:
于是,尝试去终端去ping 其中的ip,一个个的试,终于有一个通了,找对了对的ip后,就要去hosts文件修改ip-域名的映射信息了。
我习惯用nano编辑,操作如下:
输入命令:sudo nano /private/etc/hosts
然后直接用常规编辑文本的方式修改github对应ip,然后control+o命令保存,回车,control+c退出
ping github.com 不再超时。
于是重新回到项目目录下 pod install,情况如下:
Failed to connect to 127.0.0.1 port 1080: Connection refused
结果:拒绝连接错误
解决思路:端口不对,根据经验:多半是git配置里面的 代理出问题了, 突然想起最近换了梯子,打开梯子,查看端口号,果然端口号对不上,于是准备换git配置里面的端口号。
清除代理设置:命令如下:git config --global --unset http.proxy
git config --global --unset https.proxy
重新设置代理:命令如下:git config --global http.proxy http://127.0.0.1:(代理端口号)
git config --global https.proxy http://127.0.0.1:(代理端口号)
之后重新回到项目目录下 pod install,success。