-
Notifications
You must be signed in to change notification settings - Fork 847
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
WSL2 system_proxy-to-env_var translation fails to translate 127.0.0.1, making local proxy unreachable #10379
Comments
Same -- shell works, but copilot chokes. |
I had the same problem. |
I'm a little fuzzy on details here? Is the proxy running on the host(windows)? And you want to access the proxy from the guest(WSL)? |
Yes, if you open the Clash system proxy on Windows, wsl will automatically set the environment variable to http://127.0.0.1:7890, https://127.0.0.1:7890. so you cannot access the windows proxy from wsl. For example, you must manually set http://172.30.192.1:7890, https://172.30.192.1:7890 on wsl to override the environment variables automatically set for wsl to use the proxy on windows through LAN. |
Yes.I set proxy using |
That's it.I found that when i unset |
Yes and yes. It's not uncommon for us in China to speak some weird censorship-resistant proxy protocol over the Internet, but to make them usable by local programs you got to translate it down to SOCKS.1 And to make the whole system respect the thing, you need to change the system proxy settings -- because Windows wants HTTP, you run an additional HTTP proxy over the SOCKS.2 We have neat little graphical tools to both run the local proxy and change system settings like "Clash for Windows". 1 You could of course pretend that the SOCKS is a tunnel adapter, but that doesn't quite work like a real adapter (think VPN) because SOCKS only does TCP and UDP -- you don't get things like ICMP. Some words of clarification. Other people have answered the question well already.
"open" is supposed to be "enable". Same word for "open" "turn on" in Chinese. See https://en.wiktionary.org/wiki/%E6%89%93%E9%96%8B#Chinese. |
This issue has been automatically closed since it has not had any author activity for the past 7 days. If you're still experiencing this issue please re-open it. Thank you! |
Bruv... |
Any solution now? |
This comment was marked as off-topic.
This comment was marked as off-topic.
@tohsaka888 听着很像WSL1,你确定你的WSL版本是2而不是1吗?我记得以前用WSL1的时候就是这样,windows开着代理,WSL1的流量就会自动走代理,根本不用配置,应该是WSL1存在某种机制,访问宿主机的端口就像访问自己本地的端口一样,但是这个机制在WSL2被砍掉了。powershell中运行一下命令 @tohsaka888 Sounds just like WSL1, are you sure your WSL version is 2 and not 1? I remember this was the case with WSL1, when windows runs the proxy software, internet traffic from WSL1 will automatically go to the proxy, no configuration at all. There should be a mechanism in WSL1, allow access the host port like own local port, however this mechanism was cut in WSL2. Run |
Why do you just have to write some incoherent machine-translated comment?
OF COURSE I KNOW WSL2 makes a local network. That's the whole reason why I am requesting a translation, because an address other than 127.0.0.1 is needed. I have done manual translations that work, but it should be automated, because the feature is otherwise broken.
First of all, I've managed to make it work, so I'm suffering from none of these user issues. Secondly, my WSL opens straight to root. What sudo?
Yes that's the problematic translation mechanism. Your condescending "advice" only shows that you don't understand the situation. Take this stuff somewhere else. |
😅好好好,@Artoria2e5 要这么玩是吧😅 |
Sorry, I make all misunderstand. I promise to remove the irrelevant answer comment as soon as possible. In addition,
I means user @tohsaka888 is probably in the WSL1 operating environment. The advice is |
tohsaka888 is obviously in WSL2 because he described being unable to reach 127.0.0.1:7890. He confirmed that Rollinon's solution, which is WSL2-only, works, for Fred's sake. In other news, I've found a way to clear that env var in vscode: HOST=$(grep nameserver /etc/resolv.conf | cut -d ' ' -f 2)
sed -i -e '2i unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY' -e "3i export all_proxy='socks5://$HOST:7890'" .vscode-server/bin/*/bin/code-server That changes the Do make sure your VPN exit node is not blocked by copilot. I tried it on copilot chat and it took it quite a while. Oooohh thumbs down! very scary! |
Thanks for your advice, but i am acturally in WSL2, and i found some solution now. Edit export all_proxy=""
export http_proxy=""
export https_proxy=""
export HTTP_PROXY=""
export HTTPS_PROXY="" and type HTTPS_PROXY=
HTTP_PROXY= Then, we can use vscode plugin without any error. |
Maybe set networkingMode to "mirrored" in .wslconfig could resolve this issue read this Advanced settings configuration in WSL |
I'm sorry, but it doesn't work for me. |
When i use
and here is my
|
Please check ip address in wsl, i think it need to be same with your host. |
I do have this same problem. And I tried to fix it in a not elegant way. I edited # add proxy
export hostip=$(ip route | grep default | awk '{print $3}')
export socks_hostport=7890
export http_hostport=7890
alias proxy='
unset ALL_PROXY
unset HTTPS_PROXY
unset https_proxy
unset HTTP_PROXY
unset http_proxy
unset all_proxy
export https_proxy="http://${hostip}:${http_hostport}"
export http_proxy="http://${hostip}:${http_hostport}"
export ALL_PROXY="socks5://${hostip}:${socks_hostport}"
export all_proxy="socks5://${hostip}:${socks_hostport}"
'
alias unproxy='
unset ALL_PROXY
unset HTTPS_PROXY
unset https_proxy
unset HTTP_PROXY
unset http_proxy
unset all_proxy
'
alias echoproxy='
echo $ALL_PROXY
echo $all_proxy
echo $https_proxy
echo $http_proxy
'
unproxy
#end proxy 在官方有结果之前,这样似乎是一个办法 |
Mirrored 的目的就是不用折腾这个。
又绕回老办法了(笑)。至少比我 issue description 里面硬写 ip 好,但是建议
说起来 @tohsaka888,用 sed 硬改 code-server 脚本试过了吗? |
Mirrored 的结果是为了保持ip和主机一致啊,如果没生效后面的也没必要查了,至少我这mirrored加上hostAddressLoopback=true后,vscode server不会有问题😂 |
同,我最后使用mirror解决了,剩下的不会😢
这里还有一个小坑😣,使用Goland的之类IDE的时候,如果使用测试用例,还是会走127.0.0.1:7890,如下面的报错
|
没有,我目前也是用了一种不太优雅的方法解决的。 我在上层路由固定了本机的IP地址,然后在vscode中Http: Proxy设置为固定的ip + 7890端口。 通过这种方式,vscode插件确实可以联网了,并且可以使用本机代理,非常的不优雅,但是有用,😂 |
兄弟,你直接.wslconfig改成mirror就可以了吗,我记得我改成mirror之后vscode插件还是无法联网😂 |
请问能不能具体说一下你遇到的问题,我没有太明白你说的问题,因为我使用Goland🤣 $Env:http_proxy="http://127.0.0.1:7890";$Env:https_proxy="http://127.0.0.1:7890" 可以解决大部分问题 |
hostAddressLoopback设了吗 |
|
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request. Thank you! |
Windows Version
Microsoft Windows [Version 10.0.22631.2129]
WSL Version
1.3.15.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.90.4-microsoft-standard-WSL2 (root@4b885f886b45)
Distro Version
Debian GNU/Linux trixie/sid
Other Software
Clash For Windows, v0.20.12
Repro Steps
apt update
.Expected Behavior
apt update
should go through my proxy.Actual Behavior
Output similar to
Diagnostic Logs
This part is not useful. What is useful is:
See? WSL took the Windows proxy settings into Debian, but forgot that 127.0.0.1 means something else here. The snippet in
/etc/profile.d/proxy.sh
fixes the problem in shell, but not in WSL VSCode:Recommended fix
All forms of
localhost
,[::1]
,127.0.0.1
should be replaced with a reference to the parent machine, preferably using a hostname, and not this ad-hoc nameserver trick currently documented.$HOSTNAME.local
is almost sufficient: my Windows hostname being "Arisu", runningnslookup arisu.local
andnslookup arisu
does correctly return the needed name 127.27.16.1, except also returns a lot of useless addresses for other Windows network adapters like "192.168.56.1", "192.168.53.2", "172.19.64.1", and finally my LAN "10.0.1.212".The text was updated successfully, but these errors were encountered: