LoveProgramming
LoveProgramming

Reputation: 2181

Unable to connect to git remote repository

After performing git push -u origin master, I got:

fatal: unable to access 'https://github.com/xxxx/xxxx.git': Failed to connect to 127.0.0.1 port 8087: Connection refused

Same error occurred, when I tried to clone other repositories, too.

The Port 8087 doesn't seem to be busy. What could go wrong?

Edit: when I do clone from git:// instead of https://, it works just fine.

Upvotes: 47

Views: 142971

Answers (5)

Laurent
Laurent

Reputation: 1749

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

Upvotes: 86

Mahgolsadat Fathi
Mahgolsadat Fathi

Reputation: 3325

git config --global --unset http.proxy

Upvotes: 23

tdv kiran
tdv kiran

Reputation: 53

I had tried all the methods mentioned above, but I was missing something other than what they have mentioned,

try to update your credentials in Control panel -> User Accounts -> Credential Manager for Git it worked for me

Upvotes: 1

Sisi Liao
Sisi Liao

Reputation: 71

Laurent's answer worked for me. (I am behind corporate firewall.) In my case,

  • I removed the proxy setting in .gitconfig file.

  • Everything just work fine. I can clone from a remote repo.

  • When i wanted to push to the remote repo, I generated a ssh key. Then I am able to push.

Hope it saves someones 2 hours.

Upvotes: 7

toydarian
toydarian

Reputation: 4584

It seems that git tries to use a local proxy.

Please check your global network-settings and those of git.

Use git config http.proxy and git config --global http.proxy to get the proxy-settings of git.

Upvotes: 3

Related Questions