“Failed connect to mirrors.aliyuncs.com:80; Connection refused” 错误解决

CentOS7的yum源默认是国外的源,下载没有国内源稳定,所以我们经常将CentOS7换源为国内的yum源,但换源过程中有时也会遇到错误,本篇文章将介绍更换CentOS7的yum源为国内阿里云yum源时遇到的”Failed connect to mirrors.aliyuncs.com:80; Connection refused” 错误的解决方法。

该错误发生在我们去清除并重新生成yum缓存的时候。在下载包时显示”Failed connect to mirrors.aliyuncs.com:80; Connection refused” 错误,导致下载失败,影响到我们yum的正常安装和后续使用。

yum004 2 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 错误解决
yum005 2 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 错误解决

“Failed connect to mirrors.aliyuncs.com:80; Connection refused” 错误是指当前系统没有办法连接到mirrors.aliyuncs.com:80端口去下载文件,这是因为官方的链接调整导致的,解决办法就是去更改CentOS-Base.repo文件中的链接mirrors.cloud.aliyuncs.com为mirrors.aliyun.com。

解决方法是终端执行下面命令修改CentOS-Base.repo文件中的链接:

sed -i 's/http:\/\/mirrors.cloud.aliyuncs.com/url_tmp/g'  /etc/yum.repos.d/CentOS-Base.repo &&  sed -i 's/http:\/\/mirrors.aliyun.com/http:\/\/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/CentOS-Base.repo && sed -i 's/url_tmp/http:\/\/mirrors.aliyun.com/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/http:\/\/mirrors.aliyun.com/http:\/\/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
#修改CentOS-Base.repo文件中的链接mirrors.cloud.aliyuncs.com为mirrors.aliyun.com
yum006 2 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 错误解决

修改好之后,我们再次清除并重新生成yum缓存。

yum clean all #清理yum缓存
yum makecache #重新生成新的yum缓存
yum007 3 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 错误解决

这次下载全部成功,问题解决!

此条目发表在CentOS, Linux分类目录,贴了, , , , , , 标签。将固定链接加入收藏夹。

发表回复