You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS 8下Git Clone GitHub遇443端口超时,设代理仍无效求助

解决CentOS 8下Git Clone GitHub 443超时问题

一、验证代理配置有效性

  • 先检查当前Git的代理设置:
    git config --global --get http.proxy
    git config --global --get https.proxy
    若输出为空,说明代理未生效;若有配置值,先确认代理地址、端口是否正确,带账号密码的代理格式应为:http://username:password@proxy-host:port
    重新配置代理命令:
    git config --global http.proxy "http://你的代理地址:端口"
    git config --global https.proxy "http://你的代理地址:端口"
  • 用curl测试代理连通性:
    curl -x http://代理地址:端口 https://github.com
    若curl也超时,说明代理本身无法访问GitHub,需联系公司运维确认代理权限或端口开放情况

二、排查系统网络层面问题

  • 测试DNS解析是否正常:
    ping github.com
    若无法解析,临时修改/etc/resolv.conf添加公共DNS:
    nameserver 8.8.8.8
    nameserver 1.1.1.1
    
    重启NetworkManager生效:
    systemctl restart NetworkManager
  • 排查防火墙/SELinux拦截:
    临时关闭防火墙测试:
    systemctl stop firewalld
    临时关闭SELinux:
    setenforce 0
    若此时git clone成功,需在防火墙添加GitHub 443端口访问规则,或调整SELinux策略

三、切换为SSH协议克隆

若HTTPS协议始终有问题,可改用SSH协议:

  • 生成SSH密钥(无密钥时执行):
    ssh-keygen -t ed25519 -C "你的邮箱"
    全程回车使用默认配置
  • 将~/.ssh/id_ed25519.pub中的公钥内容添加到GitHub账号的SSH密钥列表
  • 替换克隆地址为SSH格式,例如将https://github.com/username/repo.git改为git@github.com:username/repo.git

四、尝试取消Git代理设置

部分公司环境下内部可直接访问GitHub,或代理规则限制访问,可取消代理后测试:
git config --global --unset http.proxy
git config --global --unset https.proxy

内容的提问来源于stack exchange,提问作者user21223915

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 00:05:20