Failed to connect to github.com port 443: Timed out
用Git去Clone項目的時候報錯:Failed to connect to github.com/gitee.com port 443: Timed out
如果不是你的網絡錯誤,那一般就是代理設置錯誤了。特別是在公司內網,需要代理登陸外網時。
1.開啓全局的git代理
因爲我們公司代理是需要ip,端口,賬號,密碼的,所以在網上找資料不太好找,大部分的資料都是不需要賬號密碼的。好不容易找到一個照着配,[link]https://www.jianshu.com/p/b3154ae86fe2 ,作者寫的很認真,很給啓發,但是卻錯了。
原代碼是這樣的:
git config --global http.proxy http://wangrui:P!1234@http://proxy.pjs.com:9090
git config --global https.proxy https://wangrui:P!1234@https://proxy.pjs.com:9090
實際上應該是這樣的:
git config --global http.proxy http://wangrui:[email protected]:9090
git config --global https.proxy https://wangrui:[email protected]:9090
然後還有個問題,上述的密碼中有特殊符號!,如果你直接運行,git會報錯,需要encode轉義一下。
最終正確的應該如下:
git config --global http.proxy http://wangrui137:P%[email protected]:9090
2.關閉代理
git config --global (或 --local) --unset https.proxy
git config --global --unset http.proxy
3.查看是否生效
git config --get --global http.proxy