IP Address Mismatch on signing into Heroku CLI

The accepted answer (run heroku login -i) doesn't work for accounts with MFA enabled. What I did instead was to reveal my account's API key and put it into ~/.netrc like so:

machine api.heroku.com
  login <MY_EMAIL>
  password <API_KEY>
machine git.heroku.com
  login <MY_EMAIL>
  password <API_KEY>

And voila! I can now use the CLI. This worked for me with Google CloudShell.

P.S. -- I added my machine's SSH key but could not understand how to use that to configure the CLI's access. It seems hard-coded to look for API keys in ~/.netrc.


Copy and paste heroku login -i in your terminal. This is what solved it for me.


Just adding some detailed steps to resolve the issue

  1. Navigate to https://dashboard.heroku.com/account/applications
  2. In Authorizations click on create authorization button
  3. Add description in pop up eg.heroku cli and leave expire after blank if you dont want it to expire
  4. You will get authorization token
  5. in cli run heroku login -i
  6. when it prompts for password enter the authoriation token