AWS EC2 Ubuntu 22.04 LTS 无法更新软件源问题求助
无法在AWS EC2 Ubuntu 22.04实例中更新软件源的问题
系统信息
执行lsb_release -a命令输出如下:
ubuntu@ip-172-31-81-55:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy
问题描述
执行apt update时无法更新软件源,报错信息如下:
Err:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease Could not connect to us-east-1.ec2.archive.ubuntu.com:80 (172.31.81.55), connection timed out Err:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease Unable to connect to us-east-1.ec2.archive.ubuntu.com:80: Err:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease Unable to connect to us-east-1.ec2.archive.ubuntu.com:80: Err:4 http://security.ubuntu.com/ubuntu jammy-security InRelease Could not connect to security.ubuntu.com:80 (91.189.91.83), connection timed out Reading package lists... Done W: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/dists/jammy/InRelease Could not connect to us-east-1.ec2.archive.ubuntu.com:80 (172.31.81.55), connection timed out W: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Unable to connect to us-east-1.ec2.archive.ubuntu.com:80: W: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Unable to connect to us-east-1.ec2.archive.ubuntu.com:80: W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Could not connect to security.ubuntu.com:80 (91.189.91.83), connection timed out W: Some index files failed to download. They have been ignored, or old ones used instead.
解决步骤
1. 检查网络连通性
- 执行
ping us-east-1.ec2.archive.ubuntu.com和ping security.ubuntu.com,确认实例能否连通软件源服务器 - 若无法ping通,检查EC2实例的安全组规则,确保出站流量允许访问80、443端口
- 确认实例所在VPC的互联网网关/NAT网关配置正常,实例拥有公网访问权限
2. 更换软件源
如果网络连通但默认源无法访问,可切换至国内镜像源:
- 备份原有源文件:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - 编辑源文件:
sudo nano /etc/apt/sources.list - 将原有内容替换为阿里云Ubuntu 22.04镜像源:
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 - 保存退出后执行更新:
sudo apt update
3. 检查代理配置
- 若实例使用代理,检查
/etc/apt/apt.conf或/etc/apt/apt.conf.d/下的代理配置文件,确保代理地址、端口正确,且代理服务器可访问软件源
内容的提问来源于stack exchange,提问作者Santhosh
相关产品推荐
相关产品推荐

