29

I recently started collaborating in a project on Heroku using Ruby on Rails. I was added as a collaborator and added the remote to my environment. After some development, I pushed some changes and had no problems:

$ git push staging

Where staging is the name of my remote. Later, when trying to run "rake test" on Heroku, I recieved an error:

$heroku run rake test --app staging
Running `rake test` attached to terminal... failed
 !    You do not have access to the app staging.

Which is odd, as I was perfectly able to push my own changes. I checked the Heroku dashboard and saw that my push was logged there. I then tried to view the logs using the console, and the same problem occured.

$ heroku logs --app staging
 !    You do not have access to the app staging.

Finally, I tried to access the console, but it failed as well.

$ heroku run rails console --app staging
Running `rails console` attached to terminal... failed
 !    You do not have access to the app staging.

At this point I updated my Heroku toolbelt installation, and used "heroku auth" to verify that my email was showing up, but the error persists. I'm currently contacting Heroku support but I'm hoping someone with a similar issue could aid me in parallel.

Thanks!

Yael Herrera Halley
  • 1,183
  • 1
  • 8
  • 8

8 Answers8

79

So just in case anyone is having a similar problem, this occurs because I was mixing the name of my Heroku Apps with the name of my git remotes. So when I was calling --app staging (the name of my remote), I should have been using the actual name of the app, as found in Heroku.

Yael Herrera Halley
  • 1,183
  • 1
  • 8
  • 8
  • 3
    Thank you, this is helpful. It's confusing because if you run $ heroku run bash without an app name it gives you a warning that there are multiple apps and then lists the names of the git remotes. So I kept trying to select an app using the remote name as well. – Jared_C Jan 21 '16 at 22:43
20

Be sure to run heroku login before using Heroku toolbelt commands for the first time. It will not tell you that you have not signed in before.

IAmNaN
  • 10,305
  • 3
  • 53
  • 51
  • are help for situations where `heroku create` was accidentally run before `heroku login` was run? I have no clue how to reverse this. – Smokin Joe Apr 04 '18 at 19:40
9

This happen also when you haven't added heroku git remote repository.

You can add it with this command:

git remote add heroku https://git.heroku.com/<your project>.git

You can also type

heroku git:remote -a AppName
Montells
  • 6,389
  • 4
  • 48
  • 53
1

I had the same problem because I had created multiple remotes on heroku (e.g. a remote called "staging" for staging, and the default remote "heroku" for prod).

Solution

Use these two options to let heroku know which app and remote you're referring to:

  1. -a your_app_name, and
  2. --remote name_of_remote

Examples

For example, for the remote called staging:

heroku run env -a your_app_name --remote staging

or like this for the production remote:

heroku run env -a your_app_name --remote heroku

Extra Info

The above code runs the simple command env, but you can replace that with whatever commands you want to run on heroku.

Replace the name of the remote. By default, heroku creates one remote called heroku, which is typically the production remote. You can get your remotes with the command: git remote.

stevec
  • 41,291
  • 27
  • 223
  • 311
0

This was caused of your ssh key is no more permited to access. Make sure your ssh key is same. You can also regenarate your ssh key and add this to heroku.

Md Sirajus Salayhin
  • 4,974
  • 5
  • 37
  • 46
0

You can also run:

heroku run rake test --remote staging

Not sure what happens under the hood, but locally the CLI tool figures out which app you mean based on your git remote.

bschaeffer
  • 2,824
  • 1
  • 29
  • 59
0

I had the same problem in my case I was not pushing from master so I had to use this: git push heroku :main

0

I had the same problem. It was cause I was not login in Heroku. First I type:

heroku login then i type: heroku git:remote -a restserver-node-jngs and it works.

I hope it be helpfull for someone.