项目场景:
需要在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