You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSL Ubuntu 18.04执行sudo apt update遇临时错误求解决方案

WSL Ubuntu 18.04 sudo apt update临时错误的额外排查方案
  • 强制切换至WSL2网络模式(若当前为WSL1)
    打开管理员权限的Windows命令提示符,执行:

    wsl --set-version Ubuntu-18.04 2
    

    切换完成后重启WSL,再尝试执行更新命令。

  • 替换Ubuntu软件源为国内镜像
    先备份原源文件:

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    

    编辑源文件:

    sudo nano /etc/apt/sources.list
    

    清空原有内容,粘贴阿里云18.04镜像源:

    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    

    保存退出(按Ctrl+O回车,再按Ctrl+X),然后执行:

    sudo apt clean && sudo apt update
    
  • 重置WSL网络配置

    1. 关闭所有WSL实例:
      wsl --shutdown
      
    2. 打开管理员权限的Windows命令提示符,执行以下命令重置网络:
      netsh winsock reset
      netsh int ip reset all
      netsh winhttp reset proxy
      ipconfig /flushdns
      
    3. 重启电脑后,重新启动WSL并尝试更新。
  • 检查Windows防火墙规则
    打开Windows Defender防火墙,确认未阻止WSL相关网络请求。可临时关闭防火墙测试,若更新正常,再添加允许WSL通过防火墙的规则。

  • 重新安装WSL Ubuntu 18.04(最后手段)
    备份WSL内重要数据后,执行:

    wsl --unregister Ubuntu-18.04
    

    从Microsoft Store重新安装Ubuntu 18.04,恢复数据后再尝试更新。

内容的提问来源于stack exchange,提问作者Sophiya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 17:52:07