Ahlem Tbini
Ahlem Tbini

Reputation: 361

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

I'm having a problem with my Git account. Every time I execute git push, I get the following error:

Git push error

I discovered that I'm working with an SSH URL:

SSH URL

I tried switching back to an HTTPS URL using the following commands:

git config --global url.https://github.com/.insteadOf git://github.com/
git config --global url."https://".insteadOf git://

However, it doesn't seem to change anything: example

I tried many options that I thought were solutions such as manually configuration of config file but nothing works.

Upvotes: 25

Views: 48041

Answers (5)

Amar Singh
Amar Singh

Reputation: 940

This error occurred because your git port is restricted.

You can get it fixed with the following command:

git config --global url.https://github.com/.insteadOf git://github.com/

By doing this globally it will also repair other issues where perhaps old repositories or other scenarios may be using git instead of https when the git:// port/protocol may not be functional now vs earlier.

Upvotes: 84

Ramiro G.M.
Ramiro G.M.

Reputation: 477

In my case I figured out my flutter project was trying to fetch a dependency from an URL on the pubspec.yaml with the following format: "git:github.com/repository"...To fix it I just had to change the "git" for "https".

Upvotes: 1

simlmx
simlmx

Reputation: 1333

I had this error while running git submodule update --init.

I fixed the problem by changing all my git:// submodules to https:// submodules in the .gitmodules file.

Then I ran

git submodule sync

After that my submodule update worked properly.

Upvotes: 2

deric4
deric4

Reputation: 1326

So there's a few things going on here I think:

  1. The error from your first screen shot looks like it may be caused by having cloned the repository using the plain git:// protocol which doesn't do any type of authentication/authorization. Meaning you can git pull but you won't be able to git push.

  2. If you want to update your git config to automatically use https when pushing, you can add something like this to your gitconfig:

[url "https://github.com/"]
    pushInsteadOf = git://github.com/
  1. Alternatively if you want to use SSH instead of git:// or https:// protocol (and have your public key uploaded to your GH account) you can add
[url "[email protected]:"]
    pushInsteadOf = git://github.com/
    pushInsteadOf = https://github.com/

Upvotes: 2

Mime
Mime

Reputation: 1376

To use git with ssh, a different url syntax is needed, with git@<url> as url. According to your screenshot, the url should most likely look like this

[email protected]:ahlemtbini/blog_web.git

You can change it with the following command

git remote set-url origin [email protected]:ahlemtbini/blog_web.git

If you are using github, i recommend you to always use the url's listed under the code-button at the github-page of that repository. More information here

For more information about protocols used by git, read the page about git server protocols.

Upvotes: 4

Related Questions