在Ubuntu 24.04上安装ollama报curl: (28) Failed to connect to github.com port 443的解决方法

在一个新的Ubuntu 24.04上安装Ollama,结果报类似于:curl: (28) Failed to connect to github.com port 443 after 136027 ms: Couldn't connect to server的错,想想可能还是网络的问题。

顺便总结一下Ubuntu上设置代理的几种方法:

1. 设置------网络------代理,发现不解决问题

2. Git工具设置代理的方法,用类似于:

bash 复制代码
git config --global http.proxy 192.168.1.61:10811
git config --global https.proxy 192.168.1.61:10811

设置Git工具的http代理,例如这里介绍的:解决Git连接失败:Failed to connect to github.com port 443 after 21090 ms: Couldn't connect to server ‍-腾讯云开发者社区-腾讯云

查看Git代理设置:

bash 复制代码
git config --global -l

或者可以指明查看代理设置:

bash 复制代码
git config --global --get http.proxy
git config --global --get https.proxy

取消代理设置:

bash 复制代码
git config --global --unset http.proxy
git config --global --unset https.proxy

如果socks5代理应该这样写(我之前参考的这篇博客Git报错: Failed to connect to github.com port 443 解决方案-CSDN博客,写得是有问题的):

bash 复制代码
git config --global http.proxy socks5://127.0.0.1:1234
git config --global https.proxy socks5://127.0.0.1:1234

发现这种方法依然不能解决问题。

3. 设置临时代理,例如我这里:

bash 复制代码
export http_proxy=http://192.168.1.61:10811
export https_proxy=http://192.168.1.61:10811

发现这样确实可以解决问题。至于有些网友说的设置GitHub的IP地址,如:

https://www.cnblogs.com/sk-3/p/16900164.html

Failed toconnect to github.com port 443: 拒绝连接 Could not resolve host: github.com_github 443拒绝连接-CSDN博客

则不能解决问题(和上面这些稍有不同,我这里查到的github.com的网址是:140.82.112.3)。

上面这种方式对应的取消和查看代理的方法:

bash 复制代码
#取消代理
unset http_proxy
unset https_proxy
unset socks5_proxy
#查看代理
env |grep -i proxy

还有网友总结了conda代理设置,和增加永久代理的方法,参考:

linux(ubuntu)常用的代理设置_bashrc 加入代理-CSDN博客

还有朋友介绍了怎么用简单命令来代替上面的设置和取消代理:

https://zhuanlan.zhihu.com/p/689730386

这里介绍的也一样,不过介绍了三处配置文件:[ubuntu]ubuntu终端代理和清除终端代理命令-CSDN博客

就简单总结这么多。

相关推荐
数智化精益手记局5 分钟前
什么是安全生产?解读安全生产的基本方针与核心要求
大数据·运维·人工智能·安全·信息可视化·自动化·精益工程
70asunflower10 分钟前
Ubuntu `tree` 命令完全指南:让目录结构一目了然
linux·数据库·ubuntu
老四啊laosi10 分钟前
【Linux系统】16. 进程程序替换
linux·exec·程序替换
zjeweler15 分钟前
好淘云:低成本云服务器选型与实战应用指南
运维·服务器
空管电小二23 分钟前
【低压断路器的选择性配合】低压配电“安全后盾“:后备保护到底是什么?
运维·经验分享·安全·学习方法
ch3nyuyu34 分钟前
IO缓冲区
linux·服务器
奇妙之二进制41 分钟前
zmq源码分析之PUSH/PULL 模式的负载均衡分析
运维·网络·负载均衡
wheeldown1 小时前
2026年4月横评三款主流远控软件实况实测:UU远程,Todesk,向日葵,综合性能 UU 远程表现最佳
linux·运维·服务器
诗句藏于尽头1 小时前
CentOS 7 源码编译安装 Python 3.11 完整教程
linux·centos·python3.11
bksczm1 小时前
Linux之基础开发工具(Ubuntu)之apt 、vim
linux·ubuntu·php