一、問題描述:Failed to connect to github.com port 443: Connection refused問題解決
當下載Nacos時報錯如下(可能你是其他與github交互的操作報錯,pull或者push等等,但原因都一樣):
Cloning into 'nacos'...
fatal: unable to access 'https://github.com/alibaba/nacos.git/':
Failed to connect to github.com port 443: Connection refused
二、解決方法一:排查代理問題
1、嘗試重置代理或者取消代理的方式
git config --global --unset http.proxy
git config --global --unset https.proxy
如果沒效果,接著往下試。
2、添加全局代理
git config --global http.proxy
git config --global https.proxy
如果以上問題還未得到解決,可能不是代理的問題,或許是DNS解析,再采用接下來的方法嘗試。
三、解決方法二:排查DNS解析問題
提示:在DNS解析前先會嘗試走hosts然后在找不到的的情況下再DNS解析,修改hosts文件域名解析就會先走hosts中的ip和域名的映射關系。
我們可以修改hosts文件,修改ip地址和域名的映射關系,步驟如下:
1、第一步:查找github.com對應的IP
首先通過網址ipaddress.com搜索框輸入github.com,查找github.com對應的IP地址:
結果頁面拉到最下邊會看到如下信息:140.82.113.3 即查到的github.com的IP地址:
2、第二步:修改hosts文件
其次找到本機的hosts文件,將查詢到的GitHub IP地址內容140.82.113.3 github.com
追加進hosts文件:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
199.232.4.133 raw.githubusercontent.com
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
127.0.0.1 eureka7002.com
127.0.0.1 eureka7001.com
10.10.255.120 hbygj-admin.hrhbbx.com
140.82.113.3 github.com
提示:
Windows大概在C:\Windows\System32\drivers\etc下
Mac在/etc下,打開訪達后,在鍵盤上按Shift+Command+G組合鍵,在窗口中輸入/etc/hosts ,即可到達hosts文件的所在位置
配置好后,再去重新操作,成功解決。
如果解決了你的問題,可以支持一下哦。