wsl http修改国内源之后,仍然无法更新的解决方法

项目场景:

需要在wsl中安装一个软件,我的wsl有一段时间没有打开了,今天打开apt update 无法更新,一直报无法连接


问题描述

首先想的是修改源,改成清华对应的http源,仍然无法更新。然后换成https,提示证书错误,需要先重装证书,装证书又需要,更新源。陷入死循环


原因分析:

我的问题是wget和ping都通但是就是apt无法更新,不应该是网络的问题,nameserver也改过,仍然无法解决。最后找到了解决方案。使用代理,将wsl挂在本地代理上,可以更新成功。


解决方案:

具体做法。

vim /etc/apt/apt.conf
增加自己的代理配置
Acquire::http::Proxy "http://proxyaddress:proxyport";
sudo apt-get update

报错信息如下

Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
  Connection failed [IP: 91.189.91.38 80]
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
  Connection failed [IP: 185.125.190.36 80]
Err:3 http://ppa.launchpad.net/ubuntu-elisp/ppa/ubuntu focal InRelease
  Connection failed [IP: 185.125.190.52 80]
Err:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Connection failed [IP: 185.125.190.36 80]
Err:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Connection failed [IP: 185.125.190.39 80]
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Connection failed [IP: 91.189.91.38 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Connection failed [IP: 185.125.190.36 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Connection failed [IP: 185.125.190.39 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Connection failed [IP: 185.125.190.36 80]
W: Failed to fetch http://ppa.launchpad.net/ubuntu-elisp/ppa/ubuntu/dists/focal/InRelease  Connection failed [IP: 185.125.190.52 80]
W: Some index files failed to download. They have been ignored, or old ones used instead
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值