14

I am working on Ubuntu 11.10 Local branch of my git-repo is up to date

I then wrote following command in terminal:

heroku create --stack cedar

And this error was printed:

Notice: on Wed, 20 June, our default stack will change to Cedar. <Shortened Blog URL>

Creating radiant-wind-7413... done, stack is cedar  
http://radiant-wind-7413.herokuapp.com/ | git@heroku.com:radiant-wind-7413.git  
Git remote heroku added

Blog URL on the Wayback Machine1

All fine till now, then I typed following in terminal:

git push heroku master

and the following error occured:

ssh: connect to host heroku.com port 22: Connection timed out  
fatal: The remote end hung up unexpectedly

1 Note: Shortened URL were allowed in 2012 but shortened URLs have now been blacklisted

Gugu72
  • 2,052
  • 13
  • 35
user1447288
  • 141
  • 1
  • 1
  • 3
  • Refer http://stackoverflow.com/questions/8742937/rails-heroku-fatal-the-remote-end-hung-up-unexpectedly – Shamith c Jun 11 '12 at 12:09

8 Answers8

20

As of November 30, 2021, the SSH Git Transport feature has been deprecated by Heroku and only HTTP transport is supported. The real shutdown of SSH was in March 2022.

You have to reconfigure the repo with :

heroku git:remote -a <app-name>

Official statement from Heroku

If you are using a remote with a different name, e.g. production then use

heroku git:remote -a <app-name> -r <remote-name>

Maybe you will have to unset ssh connections on git global config :

git config --global --unset url.ssh://git@heroku/.insteadof
git config --global --unset url.ssh://git@heroku.com/.insteadof
Obromios
  • 15,408
  • 15
  • 72
  • 127
novastra
  • 301
  • 2
  • 5
  • It would be helpful to enrich this type of answers with a link to the documentation that confirms what you're writing! – andrea.rinaldi Mar 29 '22 at 21:48
  • This sort of works, but it does not work out of the box if you are using remotes, such as staging and production app. The heroku git:remote command creates a new remote heroku, so instead using ```git push production master``` you need to do ```git push heroku master```. I would be useful if someone extends this answer to describe how to fix the problem if your remote names are not heroku. – Obromios Apr 11 '22 at 04:30
6

Most probably some sort of firewall issue or your network admin has blocked outgoing port 22 in your network.

You may use simple scrip to see your connection to Heroku by :

$ ssh -vvv git@heroku.com

If you seeing connect timed out then you may need to request your admin to unblock port 22. Alternatively may access Heroku via tunneling as per my answer in Connecting to heroku using port 443

Community
  • 1
  • 1
AzizSM
  • 6,199
  • 4
  • 42
  • 53
5

I had the similar problem with keys. Ok this is what I did.

Check the status of your keys with

heroku keys

It shows you list of keys that are added to heroku. You can always generate new keys and add them to heroku.

ssh-keygen -t rsa

Generates new key.

heroku keys:add

adds the keys to heroku. Before adding it lists the available keys that you can add. Enter the option and you key is added to heroku.

This article can be helpful. If that doesn't work then there should be some problem with ssh. Try doing an ssh localhost and see if ssh is working.

Maddy
  • 1,233
  • 2
  • 12
  • 20
2

Today Heroku uses git over ssh. The default port for ssh is 22 and it looks like your network doesn't allow outbound connections to port 22. Perhaps this is something your network administrator can change.

James Ward
  • 29,283
  • 9
  • 49
  • 85
  • For some company it is very difficult to deal with company's Administrator / policy any alternative to this ? – AzizSM Sep 24 '13 at 08:29
  • Not that I'm aware of. – James Ward Sep 24 '13 at 21:49
  • 2
    @JamesWard but if I"m just doing this from home who exactly is the network administrator? I'm very confused as to how this literally worked 5 hours ago and suddenly stopped. Nothing about my setup has changed. – james Mar 15 '22 at 05:41
1

I had been working on this for hours trying to figure out how I could suddenly have a closed port 22, etc. when literally 5 hours ago everything was working and nothing had changed.

Finally I just reset my Git repo on Heroku and repushed everything. Still no idea what happened.

heroku plugins:install heroku-repo
heroku repo:reset --app appname
james
  • 3,989
  • 8
  • 47
  • 102
  • 2
    I had the same experience today but this did not work for me. I was able to push again after switching from ssh to https remote connection. – RobDil Mar 15 '22 at 14:14
  • 1
    Switching to https worked for me too. See https://devcenter.heroku.com/changelog-items/2301 – tquill Mar 17 '22 at 01:50
  • yeah as of May 1 2022, the deprecation appears to have really kicked in, @novastra's answer is the way to go – james May 02 '22 at 17:40
0

Do following steps.

ssh-keygen -t rsa
heroku keys:add
heroku keys  # lists keys
Shamith c
  • 3,719
  • 3
  • 25
  • 33
0

I added the https url to the .git/config file in my project folder. I found the HTTPS URL in the project Settings on Heroku. I then added that URL to replace the SSH url inside the .git/config text file.

dlp21103
  • 3
  • 2
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 18 '22 at 13:51
0

For me helped destroying whole app and recreating again - leaving it here for future reference.

heroku apps:destroy appname
heroku apps:create appname
heroku git:remote -a appname
git push heroku master
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31328902) – High-Octane Mar 26 '22 at 06:43