简体   繁体   中英

Cannot git push to heroku master for ruby.railstutorial.org

I am working on the ruby.railstutorial.org and I am having all sorts of trouble getting my first_app to push from git to heroku. I have tried the solutions listed below but keep getting back the same error messages.

Solutions I have tried: git push heroku master gives error ssh: connect to host heroku.com port 22: Connection refused git push heroku master gives error ssh: connect to host heroku.com port 22: Connection refused

I have tried precompiling as:
$ rake assets:precompile
$ git add .
$ git commit -m "Add precompiled assets for Heroku"

and getting a new ssh key. I can't seem to get anything to work. Here is what I am getting:

Coreys-MacBook-Pro:first_app coreydavis$ heroku create
Creating radiant-oasis-3729... done, stack is cedar
http://radiant-oasis-3729.herokuapp.com/ | git@heroku.com:radiant-oasis-3729.git
Coreys-MacBook-Pro:first_app coreydavis$ git push heroku master
ssh: connect to host heroku.com port 22: Connection refused
fatal: Could not read from remote repository.

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

I know the repository exists and I have access, I can't figure out what I am missing here. Any help would be great, I am very, very new to this and don't totally understand what is going wrong despite my reading and google searches. Thanks so much.

You need to assign a public key to your Heroku account, as described in their docs .

Also, double-check that the git remote is actually the Heroku app repository that you expect it to be.

$ git remote -v

You should see your Heroku app name in the list that comes out of this command.

Another thing to check is that you are not behind a firewall that is blocking port 22. That would be unusual, but not unheard of. There are also various software that will block access to AWS/EC2; make sure you're not running anything like that since Heroku runs on EC2.

I've had this issue before. If you're public key is missing the error usually indicates it. Make sure that you've logged into your GitHub account and created the new repository there first. Then run the following on the command line:

git init
git commit
git remote add origin https://github.com/username/your_repository_name.git
git push
#you should be prompted to enter your github credentials
#your code will then be pushed to your github repository
git push heroku 
#heroku will fetch your your github repository and install to your heroku instance
heroku open
#this will open your heroku instance in a new browser window. 

Good luck!!

If you created multiple apps you'll still only have your original as the remote.

git remote -v

shows you what your remotes are named and the url. Usually you'll have it named origin and you can remove it with:

git remote rm origin

Then you need to add the new heroku app name:

git remote add origin <URL to new heroku app>

Finally push your app:

git push -u origin master

The -u tag will mark it as tracked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM