Git Fatal: unable to access Failed to connect to 127.0.0.1 port 1080: Connection refused

很奇怪,我在国内的时候开ss用git用得好好的,现在人在米国不需要ss了,git确连接不上。
今天断了ss, push之后出来这个错误提示:

fatal: unable to access ‘http://…/spring-mvc.git/’: Unable to receive initial SOCKS5 response.

然后按照 git 设置和取消代理 里的方法:

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

git config --global https.proxy https://127.0.0.1:1080

git config --global --unset http.proxy

git config --global --unset https.proxy

npm config delete proxy

# 只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global --unset http.https://github.com.proxy

然后继续报错:

fatal: unable to access ‘http://…/spring-mvc.git/’: Failed to connect to 127.0.0.1 port 1080: Connection refused

然后按照git cannot clone or push? failed to connect, connection refused里的方法,继续:

    This happens because a proxy is configured in git.

    Since it's https proxy (and not http) git config http.proxy and git config --
    global http.proxy can't help.

    1 : take a look at your git configuration

    git config --global -l
   If you have nothing related to https proxy like https_proxy=... the 
   problem is not here.

   If you have something related to https proxy then remove it from the file 
   ~/.gitconfig and try again

   2 : if it still doesn't work, unset environment variables

   Check your environment variables :

   env|grep -i proxy  
   You should have one or several lines with https_proxy=...

   Unset one by one with : unset https_proxy (or HTTPS_PROXY 
   depending of the name of the variable)

   3 : check environment variables again

   env|grep -i proxy

   If it shows nothing you should be good.

   Note : This solution can applies to http and https proxy problems. just 
   the variables name changes from https to http

我在检查环境变量时后没发现https_proxy=这类的,但是发现了一个

ALL_PROXY=socks5://127.0.0.1:1080

明显是代理,然后我在git里输入了:
unset ALL_PROXY

再次检查环境变量,回应变成了空白,说明我已经取消代理了?

然后我再次push,貌似成功了,问题就此解决。

我关闭后再次启动iTerm后发现又一次出现了同样的问题,也就是我每次启动git会默认ALL_PROXY=socks5

    原文作者:greatfulltime
    原文地址: https://www.jianshu.com/p/a08fa3eca5fe
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞