Paul Fawkesley

How to keep Heroku CLI logged in

I use the heroku command-line most days. It frequently logs out, giving this message:

▸ Invalid credentials provided.

Here’s how to keep the heroku CLI logged in for a year.

# ~/.netrc
# Regenerate Heroku Authorization annually with a 1-year expiry (31536000 seconds). See:
# * https://dashboard.heroku.com/account/applications
# * https://paul.fawkesley.com/blog/2025-01-23-how-to-keep-heroku-cli-logged-in/

machine api.heroku.com
  login your.heroku.login@example.com
  password HRKU-YOUR-NEW-TOKEN
machine git.heroku.com
  login your.heroku.login@example.com
  password HRKU-YOUR-NEW-TOKEN

That’s it. Test it by running heroku whoami.

Notes:


Thoughts? Get in touch