WSL问题: Temporary failure resolving ‘archive.ubuntu.com‘

编程入门 行业动态 更新时间:2024-10-22 08:25:50

今天在WSL进行操作的时候,发现从网络上下载东西无法成功,包括wgetapt-get 等命令都无法正常使用,比如执行sudo apt-get update 的时候会提示

Err:1 http://security.ubuntu/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu'
Err:2 http://archive.ubuntu/ubuntu bionic InRelease
  Temporary failure resolving 'archive.ubuntu'
Err:3 http://archive.ubuntu/ubuntu bionic-updates InRelease
  Temporary failure resolving 'archive.ubuntu'
Err:4 http://archive.ubuntu/ubuntu bionic-backports InRelease
  Temporary failure resolving 'archive.ubuntu'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu'
W: Failed to fetch http://archive.ubuntu/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu'
W: Failed to fetch http://archive.ubuntu/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu'
W: Failed to fetch http://security.ubuntu/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu'
W: Some index files failed to download. They have been ignored, or old ones used instead.

经过查询和搜索(解决bug真的痛苦😫),发现通过一下几行命令可以解决

sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf

接下来下载东西就都没有问题了。

参考资料: Github上的一个issue

更多推荐

WSL问题: Temporary failure resolving ‘archive.ubuntu.com‘

本文发布于:2023-06-14 01:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1424228.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:failure   Temporary   WSL   ubuntu   archive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!