1
2
3
4
wsl: 出现了内部错误。  
错误代码: CreateInstance/CreateVm/ConfigureNetworking/0x8007054f
wsl: 无法配置网络 (networkingMode Mirrored),回退到 networkingMode None。
wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。

每次一打开wsl出现这个错误都很头疼,不过我通过AI找到一个神奇的解决办法,就是有点麻烦,不过百试百灵
新建一个powershell脚本fix.ps1,键入代码:

1
2
3
4
5
6
7
8
9
# restart HNS services
net stop hns
net start hns

# reset WSL network configurations
netsh winsock reset
netsh int ip reset

# restart host computer, and set WSL network to ``mirrored'' mode.

使用管理员运行,接着重启,再次打开wsl,那个烦人的报错终于没有了🤔
虽然随着时间推移还会出现这个报错,但使用这个脚本后重启好像依然能恢复🤔