Ubuntu apt 遇见 403 Forbidden?清华镜像又抽风了,教你一键搞定(2026 年最新实测)
最近用 apt install tree 的时候,清华 TUNA 镜像(mirrors.tuna.tsinghua.edu.cn)又开始 403 Forbidden 了……
报错长这样:
Err:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/universe amd64 tree amd64 2.1.1-2ubuntu3.24.04.2
403 Forbidden [IP: 101.6.15.130 80]
E: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/universe/t/tree/tree_2.1.1-2ubuntu3.24.04.2_amd64.deb 403 Forbidden类似的问题其实从 2025 年底就开始零星出现,到 2026 年初变得更频繁。尤其是 /pool/ 目录下的 .deb 包,动不动就 403。不是你网络问题,也不是系统坏了,而是镜像站的反爬/限流策略在作祟(GitHub tuna/issues 里已经好几个相关 issue 了)。
今天分享最实用、最快的几种解决方案,按优先级排序,基本 5 分钟内就能恢复正常 apt 使用。
方案一:直接换镜像(最推荐,永久解决)
清华不稳定的时候,果断换成阿里云、中科大或华为云。速度差不多,稳定性高很多。
用命令一键换成阿里云源(Ubuntu 24.04 推荐写法)
bash
# 先备份原文件
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
# 覆盖写入阿里云源
sudo tee /etc/apt/sources.list.d/ubuntu.sources > /dev/null << 'EOF'
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
# 更新并测试
sudo apt update
sudo apt install tree -y如果想用中科大,把 https://mirrors.aliyun.com/ubuntu/ 改成 https://mirrors.ustc.edu.cn/ubuntu/ 即可。
华为云:https://mirrors.huaweicloud.com/ubuntu/
换完源后,apt update 应该秒过,tree 也能正常安装了。
图形界面换源(有桌面环境更方便)
软件与更新 → Ubuntu 软件 → 下载自 → 选「Other」→ China → 阿里云 / 中国科学技术大学 → 关闭 → 自动刷新。
方案二:只想装 tree,不想换源?手动下载 .deb
清华源抽风,但官方源还能下:
bash
# 清理旧缓存
sudo rm -rf /var/lib/apt/lists/*
sudo apt update --allow-insecure-repositories # 先不管签名
# 直接 wget 官方包(tree 最新版)
wget https://archive.ubuntu.com/ubuntu/pool/universe/t/tree/tree_2.1.1-2ubuntu3.24.04.2_amd64.deb
# 安装
sudo dpkg -i tree_2.1.1-2ubuntu3.24.04.2_amd64.deb
# 验证
tree --version如果 wget 也被 403,可以加个假 User-Agent:
bash
wget --user-agent="Mozilla/5.0" https://archive.ubuntu.com/ubuntu/pool/universe/t/tree/tree_2.1.1-2ubuntu3.24.04.2_amd64.deb为什么清华镜像总 403?
简单总结几点常见原因(根据 2026 年反馈):
- 反爬虫 / User-Agent 检测(apt 默认的 User-Agent 容易被限)
- IP 限流(尤其是香港/海外 IP 频繁请求)
- 镜像同步延迟或临时维护
- 部分 .deb 文件被单独保护(可能是防盗链)
阿里云、中科大目前还没大规模出现这个问题,所以换源是最省心的办法。
小结 & 建议
- 日常首选:阿里云或中科大源,基本不翻车
- 清华党:可以等他们修(但不知道要等到猴年马月)
- 长期方案:把
/etc/apt/sources.list.d/里的源文件做个 git 管理,随时切换 - 升级建议:Ubuntu 24.04 用着还行,但别忘了定期
apt full-upgrade,也别卡在 18.04 那种 EOL 版本上(之前也遇到过签名问题)
希望这篇能帮到同样被 403 折磨的同学~