Heroku CLI: Resolving 400 and 401 errors during login
NicolasBrondinBernard
How can this authentication error be fixed so you can deploy your application on Heroku? Here's the solution.

Article published on 08/06/2021, last updated on 10/08/2026
For information: Heroku is a cloud host (PaaS) that lets you run applications directly from the code contained in a Git repository.
It is now mandatory to go through the toolbelt provided by Heroku in order to deploy applications from your terminal, particularly to log in.
The CLI installer is available for download on Heroku's official website
Since logging in using the authentication system included in Git is no longer sufficient, you will therefore have to go through the "heroku login" command.
You may then run into a 400 (or 401) error similar to the one below:
$ > heroku login
Enter your Heroku credentials.
Email: [EMAIL]
Password (typing will be hidden):
! HTTP Error: https://api.heroku.com/login 400 Bad Request
! Invalid response from API.
! HTTP 400
! {[EMAIL] [PASS]}
!
! Are you behind a proxy?
! https://devcenter.heroku.com/articles/using-the-cli#using-an-http-proxy
A seasoned eye will have noticed that this authentication method isn't the one used by the current version of the Heroku CLI. Instead of asking for your email and password, Heroku is normally supposed to directly open a browser window to retrieve authentication from the site.
This therefore means that you're using a version of the tool that's too old, which explains why you can't authenticate.
The solution
To fix this problem, nothing could be simpler: all you need to do is update the CLI using this command:
$ > heroku update
If everything goes well, a series of updates should run, and once they're finished you should be able to try logging in again:
$ > heroku login
heroku: Press any key to open up the browser to login or q to exit:
If you see the message above appear, then your problem is solved!
If not, check that your internet connection is stable, and that you're not behind a proxy that might be blocking the connection protocol.
No spam. Only free content, news, and ever more resources to level up your skills!
Join +1500 developers
No comments yet