Search code examples
windowsgitgithubnetwork-programmingrepository

Git connection problem. "fatal: unable to connect to github.com....."


I have been having a problem with my git in so long, i have tried everything i could and it din't change anything. My git works well locally, it works with init, commits, etc. The problem is when i go to make whatever with github, since making a git clone, or git push It doesn't work with either github CLI or Git Bash, or cmd. Any of those commands i put in, just yield the following error:

fatal: unable to connect to github.com
github.com[0: 140.82.114.4]: errno=Unknown error

failed to run git: exit status 128

I've been trying with some internet solution perspectives:

  • This 26 upvoted answer
  • All this solutions about geting free port 9418, Trying with Https protocol, switching among ssh and https
  • I revised host file in C:\Windows\System32\drivers\etc location for local DNS possible incorrect configuration
  • I reinstalled Git
  • I search for some network problems, and i have got ping from github.com server and tracert github.com command for viewing github request trace and it works good as well.
  • I try using the following culr command to download the main branch zip file, through cmd and it WORKED, downloading the zip file!!!:
curl https://github.com/user/repo.git | git clone url:-

(of course, replacing my user and repo names)

  • I configured git own proxy settings to unset:
git config --global --unset http.proxy
  • I made github test for conection, obtaining good results against all servers ip and all other testing things.

I think that the problem is a git configuration realated with port or network, but i don't find it


Solution

  • i solved the problem, i tried this solution but in other way. Adding this manually to the .gitconfig file, located within %USERPROFILE% directory:

    [url "https://"]
        insteadOf = ssh://
        insteadOf = git://
    

    because with the cmd commands:

    git config --global url."https://".insteadOf git://
    git config --global url."https://".insteadOf ssh://
    

    it was not setting up the configuration correctly.

    I think what was happening is that git was trying to access GitHub via ssh and the port used for that protocol is 9418, which seemed to be blocked somehow. I discovered that using netstat tool from cmd which showed me the SYN_SEND state of the requests when i tried to do git ls-remote. It is a patch solution, but it fixed it :(