whitenk whitenk - 5 months ago 31
Git Question

Heroku permission denied / unable to connect to heroku api

I've had git set up and pushed to Heroku successfully for about 6 months ( on a mac using the Github app for mac).

Yesterday suddenly I can no longer push change to heroku, I got this error message:

$ git push heroku master

Permission denied (publickey).
fatal: Could not read from remote repository.

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

After looking around a bit it seemed it might be a problem with my key.
I created a new key and added it to heroku which seemed to work:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/kat/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/kat/.ssh/id_rsa.
Your public key has been saved in /Users/kat/.ssh/id_rsa.pub.

$ heroku keys:add
Found existing public key: /Users/kat/.ssh/github_rsa.pub
Uploading SSH public key /Users/kat/.ssh/github_rsa.pub... done

But I am now getting a different error when I try to push to Heroku:

$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

Any suggestions would be much appreciated, thanks


It looks like the heroku remote got lost somewhere along the way. Do git remote -v in your shell and check if there is a "heroku" branch configured for push. It should look like this:

heroku git@heroku.com:myrepo.git (push).

If there isn't a remote branch set up, do heroku git:remote -a my-app-name and it should configure it. See also this article for more details.