无法连接in.archive.ubuntu.com:http[IP:91.189.88.161 80],更新时遇此问题如何解决?
解决Ubuntu更新时无法连接in.archive.ubuntu.com的问题
嘿,这个问题我之前折腾过好几次,大概率是网络连通性或者默认源的访问问题,给你几个亲测有效的解决办法:
1. 先确认网络是否能连通目标地址
先试试能不能ping通官方源,打开终端输入:
ping -c 4 in.archive.ubuntu.com
如果没有返回数据包,说明你的网络到这个源的连接有问题——可能是本地防火墙拦截、ISP限制,或者网络本身不稳定。可以试试切换到手机热点,或者检查系统防火墙规则(比如ufw status看看是不是开了过于严格的限制)。
2. 切换到国内镜像源(最常用的解决方案)
默认的in.archive.ubuntu.com在国内访问经常抽风,换成国内大厂的镜像源就能解决大部分问题:
- 先备份原来的源配置文件,防止改错了没法恢复:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - 编辑源文件:
sudo nano /etc/apt/sources.list - 把文件里的内容全部替换成国内源(比如阿里云的,适配Ubuntu 22.04/jammy;如果是其他版本,把
jammy换成你的版本代号,比如20.04是focal):deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse - 保存退出(按
Ctrl+O,回车确认,再按Ctrl+X),然后更新源:sudo apt update
3. 检查代理设置是否干扰
如果你系统开了全局代理,可能会导致APT无法正常连接源。可以先临时关闭代理试试:
unset http_proxy unset https_proxy sudo apt update
如果是图形界面设置的代理,去系统设置的「网络」里找到代理选项,改成「无」再重试。
4. 清除APT缓存并重新更新
有时候缓存的过期信息会导致连接错误,清掉缓存再试试:
sudo apt clean sudo apt autoclean sudo apt update
5. 检查DNS解析是否正常
如果DNS解析不了in.archive.ubuntu.com,也会出现连接失败的提示。可以临时换个公共DNS试试:
- 编辑
/etc/resolv.conf:sudo nano /etc/resolv.conf - 添加一行:
nameserver 8.8.8.8 - 保存后再运行
ping in.archive.ubuntu.com看看能不能解析出IP。注意有些系统(比如用Netplan的)这个文件是自动生成的,重启后会失效,需要修改网络配置文件来永久设置DNS。
如果以上方法都不行,还可以检查一下系统时间是否正确——时间偏差太大可能导致SSL证书验证失败,进而无法连接源服务器。
内容的提问来源于stack exchange,提问作者Alka Yadav
相关产品推荐
相关产品推荐

