19

No way to have console wired with Heroku lately:

lsoave@ubuntu:~/rails/github/gitwatcher$ heroku run console
Running console attached to terminal... 
Timeout awaiting process
lsoave@ubuntu:~/rails/github/gitwatcher$ 

Does it happen to anyone else ?

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
Luca G. Soave
  • 12,271
  • 12
  • 58
  • 109

5 Answers5

42

I had the same problem on the ISP FastWeb, which is an ISP here in Italy. Based on my Googling, it appears that they block port 5000.

To get around it for now, I am running the following:

heroku run:detached rake db:migrate

That tells it to run without waiting to connect to my machine on port 5000. Then, you can examine the logs for your process you just kicked off. (The heroku command will tell you this after you run it):

heroku logs -p run.1

That tells it to output the logs for the running process. But I found that the logs command was exiting even though my process was still running. To get around that, you can add "-t" if you want to "tail" the logs:

heroku logs -p run.1 -t   

You'll know your process is done when you see something like this in the logs:

2012-10-14T15:36:41+00:00 heroku[run.1]: Process exited with status 0
2012-10-14T15:36:41+00:00 heroku[run.1]: State changed from up to complete

I'm sure someone could whip up a script that would

  1. Run the given heroku command with run:detached
  2. Examine the output to determine what its process name was (run.1, run.2, etc)
  3. run heroku logs -p run.1 -t and show me the output
  4. exit the logs process when it sees something like State changed from up to complete
Jawa
  • 2,336
  • 6
  • 34
  • 39
Taytay
  • 11,063
  • 5
  • 43
  • 49
  • 1
    I contacted Heroku support and they were able to help me even further so that the workaround wasn't necessary. Props to Heroku. – Taytay Jan 18 '13 at 08:36
  • thanks from Italy (Fastweb user...) for the workaround. How to avoid this workaroud? I'd like to use other commands such as `run` and so on. What they did for you? – Fabio Apr 15 '13 at 19:22
  • OP wants to run the interactive console, so this solution unfortunately won't work for their use case. – user456584 Mar 21 '14 at 19:53
  • That's true - this won't work for the interactive console. It worked for me "in a pinch" though, since I usually just needed to run a command or two. – Taytay Mar 25 '14 at 19:42
  • 1
    @Taytay i just receivd a message from Heroku that says: **"You're not the first person to ask this. Unfortunately, this is not something we can do. Our one-off dyno service is platform-wide, which means it can't bind to an other port specifically for an app."** So this can't be done – Nicola Peluchetti Sep 18 '14 at 10:44
  • Weird @NicolaPeluchetti. I wonder if they changed their dyno infrastructure? – Taytay Sep 19 '14 at 19:41
18

From: http://devcenter.heroku.com/articles/oneoff-admin-ps

The heroku run process opens a connection to Heroku on port 5000. If your local network or ISP is blocking port 5000, or you are experiencing a connectivity issue, you will see an error similar to:

$ heroku run rails console
Running rails console attached to terminal... 
Timeout awaiting process

You can test your connection to Heroku by trying to connect directly to port 5000 by using telnet to rendezvous.heroku.com. A successful session will look like this:

$ telnet rendezvous.heroku.com 5000
Trying 50.19.103.36...
Connected to ec2-50-19-103-36.compute-1.amazonaws.com.
Escape character is '^]'. 

If you do not get this output, your computer is being blocked from accessing our services. We recommend contacting your IT department, ISP, or firewall manufacturer to move forward with this issue.

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
  • 2
    Any other means (than tunneling) you can suggest to configure "run" to access through any whitelisted port like 22 or via web UI? – Artem Oboturov Mar 12 '12 at 21:43
  • 3
    port 5000 isn't blocked for me, but I still am getting the "Timeout awaiting process". – Arcolye Feb 14 '13 at 04:06
  • @Arcolye, hello there! Did you figure out this problem? it seems I don't have a blockage of port 5000, but I can't connect either. Did you ever solve this? Thank you. – jlstr Jul 15 '14 at 15:42
  • How Heroku works and which ports it uses for which commands is pretty hard to figure out :) Git push uses 22 (because Heroku doesn't just support https push). Heroku pg: runs on something else, based on pg itself. Heroku run goes over port 5000. Finally, Heroku login, logout, logs, run:detached etc seem to work, so I guess they run on something like port 80 or 443. Or am I mistaken? – Rob Grant Aug 20 '14 at 11:14
3

There's a way to bypass this restriction by executing commands you were going to execute with 'heroku run ...' directly as system calls.

For this heroku command: heroku run rake db:migrate One could make a call in Ruby system("rake db:migrate")

This call could be done as a result on some HTTP GET request - you better protect by some means, so that it wouldn't be accessible for strangers.

It's not a nice way - but when you don't have a choice - it works.

Artem Oboturov
  • 4,344
  • 2
  • 30
  • 48
1

I had the same problem on the ISP FastWeb, which is an ISP here in Italy.

The most simple way to overcome the problem is set a VPN when you are using heroku run (something)

Personally I use Tunnel Bear that offer you 0.5GB of internet traffic for free

S1M0N38
  • 131
  • 2
  • 10
-1

I've just connected successfully to a console on Heroku

Is it all apps or just a single one? I'd suggest checking your heroku gem is up to date, that you can run other commands like heroku ps, restart your application via heroku restart - if you've tried these then get in touch with Heroku support as something is wrong with your application.

John Beynon
  • 37,398
  • 8
  • 88
  • 97