git/npm/yarn配置proxy解决 Connection was reset

有时候国内网络git push访问github比较卡,出现Connection was reset, errno 10054的报错。

后来我用某个V2开头的软件中转了一下,发现网页浏览能够中转,但是git push还是总中断。

仔细观察后发现,这种软件只自动中转网页和应用,但是git这种命令行它不动。

最后解决方法是:

git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809

某个V2开头的软件本地监听端口为10808,实际使用的中转端口+1=10809,通过以上命令配置后者即可。

当然一切的前提是,得会用V2……

npm

npm config set proxy http://127.0.0.1:10809
npm config set https-proxy http://127.0.0.1:10809

npm config rm proxy
npm config rm https-proxy

yarn

yarn config set proxy http://127.0.0.1:10809
yarn config set https-proxy http://127.0.0.1:10809

yarn config delete proxy
yarn config delete https-proxy

composer

// windows
set http_proxy=http://127.0.0.1:10809
set https_proxy=http://127.0.0.1:10809

//linux
export http_proxy=http://127.0.0.1:10809
export https_proxy=http://127.0.0.1:10809  

 

点赞