Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 2 tasks
zhaoqiu-china opened this issue Nov 15, 2023 · 45 comments

Comments

@zhaoqiu-china
Copy link

zhaoqiu-china commented Nov 15, 2023

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

Copy link

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.

@MikeWang000000
Copy link

MikeWang000000 commented Nov 15, 2023

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.

@gh73962
Copy link

gh73962 commented Nov 16, 2023

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

@dreamjz
Copy link

dreamjz commented Nov 16, 2023

same +1

@Dorado607
Copy link

一样的问题

@Vixb1122
Copy link

  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

@Dorado607
Copy link

  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!

@wzhuo2022
Copy link

  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~

@FlowerBirds
Copy link

  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#

@FlowerBirds
Copy link

#10650 The problem still occurs in the 2.0.9 version.

networkingMode=mirrored

@mancuoj
Copy link

mancuoj commented Nov 17, 2023

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 将继续正常启动,而不应用配置设置。

@zhaoqiu-china
Copy link
Author

一样的问题

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

@wzhuo2022
Copy link

  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

@haoenz
Copy link

haoenz commented Nov 19, 2023

  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!

@FlowerBirds
Copy link

@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:.

@String10
Copy link

  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 for me but brought one new problem: my docker engine can't start in WSL2.
if i run a simple docker command then i'll get a The command 'docker' could not be found in this WSL 2 distro.

i just delete the .wslconfig and ignore the warning while starting WSL2...

@ghost
Copy link

ghost commented Nov 21, 2023

I started getting flooded with A localhost proxy configuration was detected but not mirrored into WSL. WSL in NAT mode does not support localhost proxies. messages the other day as well. It's not breaking anything but the messages are annoying. I ended up disabling Desktop Notifications for WSL.

@csh0101
Copy link

csh0101 commented Nov 22, 2023

the same problem

@myuansun
Copy link

  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

I tried this solution and at that time the warning message

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

disappears. However, I found my Pycharm was not able to debug using the conda environment created in wsl2. I manually change the .wslconfig to

[experimental]
autoMemoryReclaim=gradual
networkingMode=NAT
dnsTunneling=true
firewall=true
autoProxy=false

and now the issue is resolved. No warning appears when I start the WSL system, nor does any error come up when I use PyCharm for debugging.

@CHNAICORP
Copy link

CHNAICORP commented Dec 2, 2023

  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

I also encountered this problem when I opened WSL-Ubuntu today. This method successfully solved my OCD. At the same time, it also solves the confusion that the Windows system agent cannot run on WSL-Ubuntu. grateful!

@Samwellwang
Copy link

  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

worked for me ~

@JIers001
Copy link

So does the problem matter? It seems that the solution above just shields the error message.

@zhaoqiu-china
Copy link
Author

Hi everyone, in the beginning, this issue was created when I failed to taste the mirrored networkingmode. Now I solved this problem and the mirrored networkingmode is ok. The cause of failure is proxy configuration exist in both .bashrc and .zshrc.

@leelesan
Copy link

wsl2导致了这个问题,如果配置文件不能生效,可以使用会wsl1版本;

@JIers001
Copy link

Hi everyone, in the beginning, this issue was created when I failed to taste the mirrored networkingmode. Now I solved this problem and the mirrored networkingmode is ok. The cause of failure is proxy configuration exist in both .bashrc and .zshrc.

Could you please offer me detailed solution since I'm a new hand. I would appreciate it.

@3biubiu
Copy link

3biubiu commented Dec 27, 2023

  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
After using this configuration, my git command not work with VPN, like:git push ssh broken pipe error

@JIers001
Copy link

Successful. Thanks!

  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
After using this configuration, my git command not work with VPN, like:git push ssh broken pipe error

@ryanvin
Copy link

ryanvin commented Dec 29, 2023

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

many thanks

@Lakphy
Copy link

Lakphy commented Jan 21, 2024

  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

worked for me!

@HayashiNiizuki
Copy link

For those who use docker desktop, just need one line like this.

[experimental]
autoProxy=false

@Pan-zc
Copy link

Pan-zc commented Feb 5, 2024

  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

I tried this solution and at that time the warning message

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

disappears. However, I found my Pycharm was not able to debug using the conda environment created in wsl2. I manually change the .wslconfig to

[experimental]
autoMemoryReclaim=gradual
networkingMode=NAT
dnsTunneling=true
firewall=true
autoProxy=false

and now the issue is resolved. No warning appears when I start the WSL system, nor does any error come up when I use PyCharm for debugging.
it also works for me.

@Dynesshely
Copy link

  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 for me.

@yuxuan-z19
Copy link

  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

It works !!

@AntonOfTheWoods
Copy link

Some of these parameters have been promoted in the latest versions of WSL, so now you can just do:

[wsl2]
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

[experimental]
# requires dnsTunneling but are also OPTIONAL
bestEffortDnsParsing=true
useWindowsDnsCache=true

@Jen1us
Copy link

Jen1us commented Apr 11, 2024

[experimental]
autoProxy=false

only this method can solve my issue,THX!!!

@Dylanma1994
Copy link

  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!

@jingyuhhh
Copy link

  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!!!!

@HajerZhang
Copy link

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

@Homura59
Copy link

Homura59 commented Jul 5, 2024

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

[wsl2]
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

[experimental]
# requires dnsTunneling but are also OPTIONAL
bestEffortDnsParsing=true
useWindowsDnsCache=true

感谢!解决了

@strongman2015
Copy link

  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去掉就可以了

@C2jeremy
Copy link

  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去掉就可以了

折腾了好久,感谢!

@wenzhuo4657
Copy link

docker代理对这个有影响吗?

@wenzhuo4657
Copy link

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

@wenzhuo4657
Copy link

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

@sleepy-shawn
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests