4

My app runs fine locally using foreman run, and when I execute my runserver.py file using python runserver.py. When I push it to Heroku, it just crashes. I even made changes to my procfile: web: python runserver.py ${PORT} so that Heroku will bind to a port number, but to no avail...I've been at this problem for almost 3 days now. First with my Procfile and now with Heroku...any help would gladly be appreciated. Additionally, I am using Python with the Flask framework for this project -- I came across Heroku forward, but it seems to be only for RoR applications..

2014-02-24T02:24:50.146153+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2014-02-24T02:24:51.323561+00:00 heroku[web.1]: Process exited with status 137
    2014-02-24T02:24:51.333621+00:00 heroku[web.1]: State changed from starting to crashed
    2014-02-24T02:24:51.334368+00:00 heroku[web.1]: State changed from crashed to starting
    2014-02-24T02:24:55.793531+00:00 heroku[web.1]: Starting process with command `python runserver.py`
    2014-02-24T02:24:57.117683+00:00 app[web.1]:  * Running on http://127.0.0.1:5000/
    2014-02-24T02:24:57.117683+00:00 app[web.1]:  * Restarting with reloader
    2014-02-24T02:23:43.987388+00:00 heroku[api]: Deploy c55f7b6 by shaunktw@gmail.com
    2014-02-24T02:23:43.987478+00:00 heroku[api]: Release v8 created by shaunktw@gmail.com
    2014-02-24T02:25:56.204701+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2014-02-24T02:25:56.204929+00:00 heroku[web.1]: Stopping process with SIGKILL
    2014-02-24T02:25:57.495657+00:00 heroku[web.1]: Process exited with status 137

Procfile:

web: python runserver.py ${PORT}

runserver.py:

from intro_to_flask import app

app.run(debug=True)
jordelver
  • 8,292
  • 2
  • 32
  • 40
ShaunK
  • 1,181
  • 5
  • 22
  • 41

3 Answers3

9

I found the answer to this issue...essentially I had to bind a port and specify the host that I am using:

In my runserver.py file I modified it using:

import os
from intro_to_flask import app

port = int(os.environ.get("PORT", 5000))
app.run(debug=True, host='0.0.0.0', port=port)

It's probably not the most elegant way of doing it.but it works.

ShaunK
  • 1,181
  • 5
  • 22
  • 41
4

You need to specify $PORT instead of ${PORT} like

web: python runserver.py $PORT
jordelver
  • 8,292
  • 2
  • 32
  • 40
  • I made the change and my app is still crashing with the same error..not sure why it would take more than 60 secs to load. – ShaunK Feb 26 '14 at 02:32
  • On Heroku's website they [talk about using gunicorn](https://devcenter.heroku.com/articles/getting-started-with-python#declare-process-types-with-procfile). Is that an option for you? I don't know much Python. – jordelver Feb 26 '14 at 10:51
2

This link gives a simple example to start Flask app with Heroku

jujuBee
  • 494
  • 5
  • 13