# 1.问题描述
hexo部署github pages时报错,Failed to connect to github.com port 443:
fatal: unable to access 'https://github.com/lx-r/lx-r.github.io.git/': Failed to connect to github.com port 443: Connection timed out
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/media/lx/data/code/blog/blog/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:526:28)
使用浏览器访问了一下github网站是可以访问的,打开linux终端,ping github.com发现没有响应,ping不同,查了下应该是dns解析有问题。
# 2.解决
linux下打开/etc/hosts文件
sudo gedit /etc/hosts
在这个文件中添加github.com对应的ip,
140.82.113.3 github.com
github对应的服务器ip可以在https://ipaddress.com/website/github.com (opens new window)查到,如下图:

添加后,执行
source /etc/hosts
再ping github.com发现可以ping通了,根本原因还是dns服务器解析不了github.com换成本地置换直接访问github.com域名对应服务器的ip。
执行hexo g -d发现hexo也可以部署成功了。