解决Connecting to 127.0.0.1:8118… failed: Connection refused.
错误背景:
安装wsl的Ubuntu20,但是和clash冲突了,关了代理才能上网。
解决:
在/home/用户名/.bashrc上加入:
unset http_proxy
unset https_proxy
同时,为了是的Ubuntu内也能连接代理,在.bashrc加入:
export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:7890";
export http_proxy="http://${hostip}:7890";
要让wsl连上主机的代理可以直接使用下面的方法
打开或创建WSL配置文件(位于C:/User/%你的用户名/.wslconfig),并添加以下内容:
[experimental]
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
参考:
[1] 配置 WSL2 使用 Windows 代理上网 _ https://solidspoon.xyz/2021/02/17/%E9%85%8D%E7%BD%AEWSL2%E4%BD%BF%E7%94%A8Windows%E4%BB%A3%E7%90%86%E4%B8%8A%E7%BD%91/
[2] 解决Connecting to 127.0.0.1:8118… failed: Connection refused.
https://www.cnblogs.com/xiaogongzi/p/12743571.html
[3] https://blog.csdn.net/weixin_62355896/article/details/134458330