Skip to content

wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。 #10753

Closed

Description

Windows Version

Microsoft Windows [版本 10.0.22621.2506]

WSL Version

2.0.9.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.133.1-1

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

Thanks for your work about wsl.
Firstly, I have tried some updates about "networkingMode=mirrored", but failed. My system version is 22H2 which is not "Release Preview Channel".
So, I delete .wslconfig file.
Finally, when I start new terminal, I see "wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。" on the terminal.
The key point is "Release Preview Channel" is requisite for mirrored network in wsl2 ?

Expected Behavior

wsl2 can be visited by other machine in local area network.

Actual Behavior

wsl2 can not be visited by other machine in local area network.

Diagnostic Logs

No response

Activity

  1. github-actions commented on Nov 15, 2023

    @github-actions
    Contributor

    Hi I'm an AI powered bot that finds similar issues based off the issue title.

    Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

    Open similar issues:

    Closed similar issues:

    You can give me feedback by thumbs upping or thumbs downing this comment.

  2. MikeWang000000 commented on Nov 15, 2023

    @MikeWang000000

    English translation:

    wsl: A localhost proxy configuration was detected but not mirrored into WSL. WSL in NAT mode does not support localhost proxies.

    I can reproduce this issue.

    • Go to Settings > Network & internet > Proxy.
    • Turn on Use a Proxy Server
    • Set Proxy IP Address: 127.0.0.1 ; Port: 8080
    • Launch wsl.exe.

    This error message displays every time I type bash or wsl then press enter. It's a bit annoying.
    Can we have a config option to turn off this message?

    Btw, I'm not using WSL in NAT mode. Here's my .wslconfig:

    [wsl2]
    networkingMode = bridged
    vmSwitch = Bridge
    ipv6=true

    Edit:

    Workarounds: Set this config in .wslconfig will suppress the error message:

    [experimental]
    autoProxy=false

    However this config will completely disable the auto proxy feature.

  3. gh73962 commented on Nov 16, 2023

    @gh73962

    same

    # Settings apply across all Linux distros running on WSL 2
    [wsl2]
    
    # Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
    memory=8GB 
    
    # Sets the VM to use two virtual processors
    processors=6
    
    # Sets amount of swap storage space to 8GB, default is 25% of available RAM
    swap=4GB
    
    uname -a
    Linux almalinux 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
    
  4. dreamjz commented on Nov 16, 2023

    @dreamjz

    same +1

  5. Dorado607 commented on Nov 16, 2023

    @Dorado607

    一样的问题

  6. Vixb1122 commented on Nov 16, 2023

    @Vixb1122
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

  7. Dorado607 commented on Nov 16, 2023

    @Dorado607
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    Works to me, also fix my problem of Pycharm debugging from wsl, thanks!

  8. wzhuo2022 commented on Nov 17, 2023

    @wzhuo2022
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    thanks~

  9. FlowerBirds commented on Nov 17, 2023

    @FlowerBirds
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    Not works for me.

    PS C:\Users\merit> cat .\.wslconfig
    [wsl2]
    processors=6
    memory=8G
    swap=8G
    localhostForwarding=true
    dhcp=false
    kernelCommandLine = vsyscall=emulate ipv6.disable=1
    nestedVirtualization=false
    debugConsole=false
    
    PS C:\Users\merit> wsl
    wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit# exit
    PS C:\Users\merit> cat .\.wslconfig
    [wsl2]
    processors=6
    memory=8G
    swap=8G
    localhostForwarding=true
    dhcp=false
    kernelCommandLine = vsyscall=emulate ipv6.disable=1
    nestedVirtualization=false
    debugConsole=false
    networkingMode=mirrored
    
    PS C:\Users\merit> wsl --shutdown
    PS C:\Users\merit> wsl
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit#
    
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit# ping www.google.com
    ping: bad address 'www.google.com'
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit#
    
  10. FlowerBirds commented on Nov 17, 2023

    @FlowerBirds

    #10650 The problem still occurs in the 2.0.9 version.

    networkingMode=mirrored
    
  11. mancuoj commented on Nov 17, 2023

    @mancuoj

    By the way:

    .wslconfig
    存储在你的 %UserProfile% 目录中。
    用于在作为 WSL 2 版本运行的所有已安装的 Linux 发行版中全局配置设置。
    只能用于 WSL 2 运行的发行版。 作为 WSL 1 运行的发行版不受此配置的影响,因为它们不作为虚拟机运行。
    要访问 %UserProfile% 目录,请在 PowerShell 中使用 cd ~ 访问主目录(通常是用户配置文件 C:\Users<UserName>),或者可以打开 Windows 文件资源管理器并在地址栏中输入 %UserProfile%。 该目录路径应类似于:C:\Users<UserName>.wslconfig。
    WSL 将检测这些文件是否存在,读取内容,并在每次启动 WSL 时自动应用配置设置。 如果文件缺失或格式错误(标记格式不正确),则 WSL 将继续正常启动,而不应用配置设置。

  12. zhaoqiu-china commented on Nov 18, 2023

    @zhaoqiu-china
    Author

    一样的问题

    mirrored目前是只有预览版有是吧?

  13. wzhuo2022 commented on Nov 18, 2023

    @wzhuo2022
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    Not works for me.

    PS C:\Users\merit> cat .\.wslconfig
    [wsl2]
    processors=6
    memory=8G
    swap=8G
    localhostForwarding=true
    dhcp=false
    kernelCommandLine = vsyscall=emulate ipv6.disable=1
    nestedVirtualization=false
    debugConsole=false
    
    PS C:\Users\merit> wsl
    wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit# exit
    PS C:\Users\merit> cat .\.wslconfig
    [wsl2]
    processors=6
    memory=8G
    swap=8G
    localhostForwarding=true
    dhcp=false
    kernelCommandLine = vsyscall=emulate ipv6.disable=1
    nestedVirtualization=false
    debugConsole=false
    networkingMode=mirrored
    
    PS C:\Users\merit> wsl --shutdown
    PS C:\Users\merit> wsl
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit#
    
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit# ping www.google.com
    ping: bad address 'www.google.com'
    LAPTOP-TC4A0SCV:/mnt/c/Users/merit#
    

    If you have set up a proxy before, you also need to delete the code that set up the proxy before. I understand that mirrored has done the same network mapping for the host and virtual machine, and no additional settings are needed. I successfully solved the problem through this method. You can try it

  14. haoenz commented on Nov 19, 2023

    @haoenz
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    Thanks a lot! It works!

  15. FlowerBirds commented on Nov 20, 2023

    @FlowerBirds

    wzhuo2022 mancuoj # experimental feature has moved to [wsl2] (https://github.com/microsoft/WSL/releases/tag/2.0.5), but networkingMode does not works for me:bug:.

  16. 21 remaining items

  17. QuantProcessing commented on Apr 23, 2024

    @QuantProcessing
    1. 打开或创建 wsl 配置文件(位于 ),然后输入以下内容:%USERPROFILE%\.wslconfig
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. 打开命令提示符并执行wsl --shutdown

    编号: https://github.com/microsoft/WSL/releases/tag/2.0.0

    THX!

  18. jytang0621 commented on Apr 27, 2024

    @jytang0621
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    Works to me, also fix my problem of Pycharm debugging from wsl, thanks!

    THANK YOU!!!!

  19. HajerZhang commented on Jul 2, 2024

    @HajerZhang

    If using this wslconfig , you can't use MPI anymore in wsl, may because the firewall stop the communication or something(i dont know),如果要用MPI别用这个

    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    
  20. Homura59 commented on Jul 5, 2024

    @Homura59

    其中一些参数已在 WSL 的最新版本中得到提升,因此现在您只需执行以下操作即可:

    [wsl2]
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    [experimental]
    # requires dnsTunneling but are also OPTIONAL
    bestEffortDnsParsing=true
    useWindowsDnsCache=true
    

    感谢!解决了

  21. strongman2015 commented on Jul 8, 2024

    @strongman2015
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    感谢。 由于一开始.wslconfig文件是txt文件类型,尝试了很久。后续把.txt去掉就可以了

  22. C2jeremy commented on Aug 14, 2024

    @C2jeremy
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    感谢。 由于一开始.wslconfig文件是txt文件类型,尝试了很久。后续把.txt去掉就可以了

    折腾了好久,感谢!

  23. wenzhuo4657 commented on Oct 24, 2024

    @wenzhuo4657

    docker代理对这个有影响吗?

  24. wenzhuo4657 commented on Oct 24, 2024

    @wenzhuo4657

    糟糕,我不能找到我的代理配置,我貌似只在主机上开启了代理设置

  25. wenzhuo4657 commented on Oct 24, 2024

    @wenzhuo4657

    当我尝试关闭了主机上的代理,报错消失了,但是我必须使用这些代理

  26. sleepy-shawn commented on Nov 21, 2024

    @sleepy-shawn

    [experimental]
    autoMemoryReclaim=gradual # gradual | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true

    配置完这个之后报错貌似消失了

  27. FanTacyTutu commented on Nov 29, 2024

    @FanTacyTutu
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    妙手回春呀大夫

  28. wenzhuo4657 commented on Dec 4, 2024

    @wenzhuo4657
  29. hz-xiaxz commented on Jan 29, 2025

    @hz-xiaxz
    1. Open or create the wsl configuration file (located at %USERPROFILE%\.wslconfig), and enter the following content:
    [experimental]
    autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    
    1. Open the command prompt and execute wsl --shutdown

    ref: https://github.com/microsoft/WSL/releases/tag/2.0.0

    Thanks for this post! According to the newest release of WSL2 for win11, the networkingMode, dnsTunneling, firewall, autoProxy settings are not experimental now, ref: https://learn.microsoft.com/en-us/windows/wsl/wsl-config

  30. Lyxien commented on Jun 13, 2025

    @Lyxien

    没有人说 %USERPROFILE% 怎么获取吗?

  31. gongfuture commented on Jun 21, 2025

    @gongfuture

    没有人说 %USERPROFILE% 怎么获取吗?

    你 win+r 输入 %USERPROFILE% 就行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions