Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 [email protected]:<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 [email protected]

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

---

Still receiving the same message.

like image 961
A Ali Avatar asked May 14 '13 16:05

A Ali


People also ask

Could not establish connection could not resolve hostname?

This error indicates that your hostname failed to translate into an IP address. Usually, this error occurs when you change the hostname of your system. Please check the details in the Address field as entered by you. Also, check if the hostname of your FTP server and IP address is correct.

Can't resolve hostname no such host is known?

In some cases, you're going to inevitably come across errors. And one such error is the “So Such Host is Known” error. As and when you get such error, it implies that either the server is down or the hostname is incorrect and hence SSH wasn't able to connect to it.

How do I find my GitHub hostname?

If you're not already on the "Site admin" page, in the upper-left corner, click Site admin. In the left sidebar, click Management Console. In the left sidebar, click Hostname.


2 Answers

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

git remote set-url origin [email protected]:<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 [email protected]:<username>/demo_app.git
  4. git commit --allow-empty -m 'First commit'
  5. git push origin master
like image 166
aymericbeaumet Avatar answered Oct 06 '22 21:10

aymericbeaumet


If you got here because you're on a proxy

Try:

ssh -T -p 443 [email protected]

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

Host github.com
  Hostname ssh.github.com
  Port 443 

More info here: https://help.github.com/articles/using-ssh-over-the-https-port/

like image 42
Ralph Cowling Avatar answered Oct 06 '22 23:10

Ralph Cowling