Cannot push to github, ssh: Could not resolve hostname

I can’t get pass this, have remade the repository multiple times, made ssh keys over

demo_app <username>$ git remote add origin<username>/demo_app.git

fatal: remote origin already exists.

$ git push -u origin master
ssh: Could not resolve hostname git: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Checked ssh keys


$ ssh -T

Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.


Still receiving the same message.

  • Gitweb failure: fatal: missing object 0000000000000000000000000000000000000000 for refs/heads/master
  • Organizing multiple scala interrelated sbt & git projects - best practice suggestions
  • Changing permissions with deep Git repository-repository -tree with sub-repos and submodules?
  • How do I find out the numbering of merge commit parents?
  • GitHub: invalid username or password
  • Git: how to reverse-merge a commit?
  • Heroku - Added SSH public key and still getting Permission denied (publickey) error
  • Add syntax highlighting to gh-pages
  • SSL works with browser, wget, and curl, but fails with git
  • Git commit that doesn't override original authors in git blame
  • How to use a Git repository as an exploded war?
  • Removing merge commits in Git
  • 3 Solutions collect form web for “Cannot push to github, ssh: Could not resolve hostname”

    Instead of adding a new remote, try to change the existing one with the following command:

    git remote set-url origin<username>/demo_app.git

    Edit: so, here are the commands to make it work without losing your code.

    1. rm -rf .git
    2. git init .
    3. git remote add origin<username>/demo_app.git
    4. git commit --allow-empty -m 'First commit'
    5. git push origin master

    If you got here because you’re on a proxy


    ssh -T -p 443

    If that works then you can add settings to your ~/.ssh/config to always connect through 443:

      Port 443 

    More info here:

    To answer the new error: “error: src refspec master does not match any. error: failed to push some refs to ‘’

    I found this post really helpful: src refspec master does not match any when pushing commits in git

    Essentially, try add your files and committing again.

    git commit -m 'initial commit'
    git push origin master

    This worked for me!

    Git Baby is a git and github fan, let's start git clone.