heroku run console returns 'Error connecting to process'
Asked Answered
T

7

30

I have deployed a rails 3.1 app to Heroku Cedar stack, and am trying to perform a:

heroku run rake db:migrate

it returns:

Running console attached to terminal... 
Error connecting to process

I also try to simply launch the console:

heroku run console

Any run command returns the same error.

Running console attached to terminal... 
Error connecting to process

Looking at the logs I get the error code:

2011-09-25T16:04:52+00:00 app[run.2]: Error R13 (Attach error) -> Failed to attach to process

When I heroku ps to see the current processes, I can see my attempts are running:

Process       State               Command
------------  ------------------  ------------------------------
run.2         complete for 26m    bundle exec rails console
run.3         up for 27s          bundle exec rails console
run.4         up for 3s           bundle exec rake db:create
web.1         up for 46s          bundle exec thin start -p $PORT -e..

But again each of them are raising exceptions:

2011-09-25T16:31:47+00:00 app[run.3]: Error R13 (Attach error) -> Failed to attach to process
2011-09-25T16:31:47+00:00 heroku[run.3]: Process exited
2011-09-25T16:31:48+00:00 heroku[run.3]: State changed from up to complete
2011-09-25T16:32:11+00:00 app[run.4]: Error R13 (Attach error) -> Failed to attach to process
2011-09-25T16:32:11+00:00 heroku[run.4]: Process exited
2011-09-25T16:32:12+00:00 heroku[run.4]: State changed from up to complete

Server Admin isnt my cup of tea, hence the decision to use Heroku.

Both Heroku docs and Googling have not led me down a path that give me much to go on.

Any ideas? This has not been my experience on the Bamboo stack.

My other errors are obviously related to DB migrations not being performed. Until I can run the rake tasks, I'm stuck moving forward.

Tremolite answered 25/9, 2011 at 16:17 Comment(1)
Interesting.. I have this problem too.Tadashi
C
82

I had the same problem, and although I did not solve the problem, I found a workaround.

Instead of using:

heroku run rake db:migrate

You can use:

heroku run:detached rake db:migrate

This runs the command in the background, writing the output to the log. When it is finished you can view the log for the result.

Not ideal, but when you are on an inadequate network, it will get you out of a hole :)

Circuit answered 16/1, 2012 at 16:18 Comment(2)
Awesome! Do you know if there's a way to execute a command after running rails c this way?Bach
heroku run:detached rake db:migrate worked for me !! Cheers Thanks mate .. :)Mescal
B
17

This problem is typically caused by a connectivity or firewall issue. You can test your connection to the heroku run and heroku console servers by running the following commands:

$ telnet rendezvous.heroku.com 5000 
$ telnet s1.runtime.heroku.com 5000

(If you are successfully able to connect, press Ctrl+] and then type quit to exit the telnet session.)

Some users have success after whitelisting these hostname+port combinations in their firewall.

Heroku mentions this in the troubleshooting section of one-off processes: http://devcenter.heroku.com/articles/oneoff-admin-ps

An application which takes a long time to boot can also exasperate connectivity issues. If the server does not respond quickly enough, your local connection will timeout before the app can boot.

Blaeberry answered 3/10, 2011 at 15:10 Comment(3)
ipfw list returns --> 65535 allow ip from any to anyTremolite
solved - tested with 3G tether and received responses, doesn't appear to be the firewall; maybe proxy, or ISP.Tremolite
Bad luck of Heroku using a port commonly banned by corporative ISPs, etc. linklogger.com/TCP5000.htmParadies
R
4

It seems this happens for different reasons. For me it turned out to be I had an older version of the Heroku Toolbelt installed. It was prior to the self-updating version and I also had old versions of the heroku gems installed. Those had to be removed before updating the heroku toolbelt had any effect.

This page proved helpful. Read it first: https://devcenter.heroku.com/articles/heroku-command#staying-up-to-date

Find out which heroku toolbelt version (if any) you are using like this:

$ heroku version
heroku-toolbelt/2.xx.x 

If it is older than version 2.32.0 then it needs to be updated. If you don't see 'heroku-toolbelt' in the response, then you need to install it.

Make sure you uninstal any old heroku gems first. Running the command below asked me if I wanted to remove the executables as well. The correct answer is YES! You can always bundle/install later if you need the gem for specific apps.

$ gem uninstall heroku --all

If you are using rbenv, you may need to rehash:

$ rbenv rehash

Once you clean out the old gems, download the current heroku toolbelt and install it. Everything should work after restarting the terminal.

EDIT:

I had to make sure my rbenv path didn't get set in front of the heroku cli path. Otherwise any bundle/install of the old heroku gem would hijack the heroku command again. I added the export path line at the end of my ~/.profile file so it would be appended before any rbenv path.

$ vi ~/.profile
export PATH=/usr/local/heroku/bin:$PATH

Reloading the terminal showed this worked by running and the path not being in /usr/local/heroku

$ which heroku
/usr/local/heroku/bin/heroku
Reducer answered 17/11, 2014 at 22:23 Comment(1)
Yep, updating the heroku CLI was the solution for me. Although the heroku docs says the cli will auto-update I hade to run heroku update to force an update.Razor
B
1

Try installing the latest version of the heroku gem and then running these "heroku run" commands again.

Batsheva answered 27/9, 2011 at 7:35 Comment(0)
F
0

It looks like a problem with a Heroku - I'm getting errors connecting to the console on applications of mine running on Cedar. You're certainly not doing anything wrong with the commands you are typing.

Footsore answered 25/9, 2011 at 17:37 Comment(0)
T
0

Solved - tested with 3G tether and received responses, doesn't appear to be the firewall; maybe proxy, or ISP.

Tremolite answered 13/11, 2011 at 17:0 Comment(0)
U
0

For me, upgrading my heroku toolbelt and cli worked. I use brew so it looks like this:

brew upgrade heroku-toolbelt
Unhandy answered 1/6, 2016 at 18:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.