heroku error: Unable to connect to heroku API - heroku

I'm trying to access heroku from my command line, and I keep getting this same error: "Unable to connect to heroku API. Please check your internet connectivity and try again."
My internet connectivity is fine.
This question has been asked on StackOverflow before, but I don't quite understand the answer that seemed to be effective, as I'm a complete newbie. Apparently, it might have to do with an environment variable?
The other answer suggested a missing heroku remote branch, but mine is set up.
What, exactly, should I do to regain my connection with heroku?
Thanks!

Get the same message "Unable to connect to heroku API. Please check your internet connectivity and try again." when using heroku toolbelt on Mac.
In my case I installed the heroku toolbelt using homebrew. Installing the heroku toolbelt from https://toolbelt.heroku.com/ can solve the issue.

Well, it seems to have been a problem with my antivirus program . . . I reinstalled that, and heroku is accessible again.

If you’re behind a firewall that requires use of a proxy to connect with external HTTP/HTTPS services, you can set the HTTP_PROXY or HTTPS_PROXY environment variables in your local developer environment, before running the heroku command.
For example, on a Unix system you could do something like this:
$ export HTTP_PROXY=http://proxy.server.com:portnumber
or
$ export HTTPS_PROXY=https://proxy.server.com:portnumber
$ heroku login
On a Windows machine, either set it in the System Properties/Environment Variables, or do it from the terminal:
> set HTTP_PROXY=http://proxy.server.com:portnumber
or
> set HTTPS_PROXY=https://proxy.server.com:portnumber
> heroku login
I Got the same error on Mac OS X 10.13, and it's work for me, since I am behind the proxy,It's gathered from the Heroku Dev center page
https://devcenter.heroku.com/articles/using-the-cli

Related

What could be the reason why "heroku open" command is not working?

I have successfully deployed a django app on heroku using this guide. The heroku cli is installed as a snap application on my system - I'm running Fedora 32 on a Dell xps 15 - and everything seems to be working fine except when I try to run the app locally.
When I attempt to run the app locally, I get the following error:
$ heroku open
▸ Error opening web browser.
▸ Error: Exited with code 4
▸
▸ Manually visit https://[myapp].herokuapp.com/ in your browser.
I tried variations of the command to no avail:
$ heroku open -a [myapp]
$ heroku open -r https://git.heroku.com/[myapp].git
When, instead, I run it with heroku local it runs without any problems.
I look at the logs but couldn't find any clues. Neither was I able to find any useful information.
What am I missing?
Try setting the browser in your ~/.bashrc using export BROWSER=
If someone uses Windows Subsystem for Linux, set the BROWSER environment variable in the corresponding shell configuration file (e.g., ~/.zshrc) to wslview.
export BROWSER=wslview

My Heroku-cli not recognizing commands. (Mac OS X)

When I run $"heroku help" in my Mac OS X Terminal, I get the following error from the Heroku Cli.
$ heroku help
▸ help is not a heroku command.
▸ Perhaps you meant help
▸ Run heroku help for a list of available commands.
And it applies to every heroku command except "heroku login".
$ heroku restart
▸ restart is not a heroku command.
▸ Perhaps you meant restart
▸ Run heroku help for a list of available commands.
etc...
Is anyone else experiencing the same problem? Or how do I fix it? Thanks.
I'm having the same issue (OSX) and was able to fix it. Here's what I did.
https://devcenter.heroku.com/articles/heroku-cli#troubleshooting
That link has some trouble shooting help. It referenced a log file so I went there.
cat ~/Library/Caches/heroku/error.log
Nothing obviously wrong for me, just references to "...is not a command", but the stack traces called out the following path.
/Users/[username]/.local/share/heroku/
I deleted that folder and did another reinstall of heroku.
Everything started working for me.
One thing I noticed was that although I had ungraded heroku and it said it was installing a new version, running the following command still declared the previous version I had installed.
heroku --version
so it sounds like it's a caching issue.

Heroku cli: Heroku create command hangs

Heroku Create command hangs while printing installing core dependencies ...
There are no errors, the process is continuously running. This happens as part of my Heroku toolbelt installation. In the website it is mentioned to use HTTP_PROXY before running heroku command, in case we are behind a firewall. I am not sure about that, is that the reason? Please help. I am using Mac El Capitan.

Setup heroku environment on different machine

I have two laptops, one work laptop and another personal laptop. I have setup the Heroku environment on the work laptop. In git repo I have added github as origin and heroku as separate remote. Whenever I need to deploy anything I just use heroku remote to push my changes.
Now I have already cloned my code from github and also installed heroku-toolbelt on the second laptop. Now I want to push my code and access Postgres database from second laptop. But not sure how to do it. I am able to see the app config parameter by this command.
heroku config --app <MY-APP-NAME>
But when I try to access database I am not able to do so. The pg sub-command doesn't provide --app option to specify the app name.
I tried to look into heroku fork but this command will basically create another app from an existing app. I don't want to do this.
I also looked into herku git:clone but this command will basically clone the repo. I have already cloned my repo from githu.
I am not sure how to have the same heroku enviornment as I have on my work laptop.
EDIT1
I executed the following command to add heroku remote in git config.
heroku git:remote -a <MY-APP-NAME>
So I don't need to specify the --app option to access the config. It automatically picks the right config. But I when I try to access the Postgres database it gives me following error.
>heroku pg:psql
---> Connecting to DATABASE_URL
sh: psql: command not found
This exact same command works on another laptop.
EDIT2
I figured out the problem. Actually heroku is trying to run psql on my local box but psql was not installed on my machine and hence it couldn't successfully connect to remote database. So I executed the following command to install psql and it worked like charm.
brew install postgres
First add the git remote by executing the following line.
heroku git:remote -a <MY-APP-NAME>
Then make sure your system has the postgres client installed. If it is not installed then installed it using the following command.
brew install postgres
The above command is only valid for Mac which has brew installed. You can search internet to find the specific command for your own platform.

Bored to write app name in every heroku command though I got only 1 app [duplicate]

This question already has answers here:
Is there a way to set a default app for Heroku Toolbelt?
(3 answers)
Closed 1 year ago.
Heroku toolbelt is always forcing me to write an app name at the end like this:
heroku pg:reset DATABASE --app [app_name]
Is there a way to set the default app to which all my CLI heroku commands will apply?
Going to post this just in case it helps someone else out. I had the same problem even though there was only one app installed. I had to switch my heroku remote url from https to git.
https://git.heroku.com/[heroku-app-1234].git
to
git#heroku.com:[heroku-app-1234].git
Then everything worked normally for myself.
git remote remove heroku
git remote add heroku git#heroku.com:[heroku-app-1234].git
If heroku is claiming that there are multiple apps in the folder you must have more than one remote in your .git/config.
Remove the extra heroku remote or set the default using git config heroku.remote remote_name
If you have the heroku-accounts plugin installed, switching to the heroku branch worked for me, as discussed in this answer.
To swap out your existing version of the heroku-accounts plugin, use:
heroku plugins:install https://github.com/heroku/heroku-accounts.git
Note that if you've followed #Moemars answer, you'll need to switch your git remote back to https.
If you run heroku from the Git repo linked to your Heroku app, you don't have to specify an app name (unless the repo is connected to multiple apps).
This seems to be the easiest way to fix the issue:
heroku git:remote -a <app_name>
Since this wasn't mentioned until now:
Apart from the git remote, the Heroku CLI also looks into the HEROKU_APP environment variable.
By using direnv, dotenv or similar tools for project-specific environments you can easily set the respective Heroku app for each project or directory.

Resources