gitgithub

GitHub Error - "ssh: connect to host github.com port 22: Operation timed out fatal: Could not read from remote repository."


I want to push a repo from my computer to GitHub. I set the remote origin

git remote add origin git@github.com:alicht/tweetanuber.git

and then after when I try pushing to GitHub

git push -u origin master

I'm greeted with this error:

ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

How can I resolve this issue and push the repo on my local computer to GitHub?


Solution

  • That indicates that the git software cannot connect to Github through SSH: this often happens if your firewall, or the firewall set up by your ISP, blocks SSH connections on port 22. A quick workaround to see if this is the problem is to try the HTTPS URL provided by Github:

    git remote add origin-https https://github.com/alicht/tweetanuber.git
    git push -u origin-https master
    

    If that works, then it's definitely your SSH port being closed. You could continue to use this alternate syntax, try to get port 22 unblocked on your computer or at your ISP, or check out the suggestion at https://stackoverflow.com/a/8081292/27310 and see if that works for you.