3

I’m hoping to deploy a flask app to Heroku using a free dyno and it seems to build successfully:

remote: Git submodules detected, installing:
remote: 
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 83.2M
remote: -----> Launching...
remote:        Released v94
remote:        https://MYAPP.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.

then checking the Heroku logs after accessing the URL i’m thrown this error:

2017-10-25T22:33:09.264449+00:00 heroku[web.1]: Starting process with command `python run.py runserver`
2017-10-25T22:33:15.514250+00:00 app[web.1]:  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-10-25T22:33:15.519730+00:00 app[web.1]:  * Restarting with stat
2017-10-25T22:33:17.300082+00:00 app[web.1]:  * Debugger is active!
2017-10-25T22:33:17.305442+00:00 app[web.1]:  * Debugger pin code: 146-142-273
2017-10-25T22:34:09.286891+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-10-25T22:34:09.286934+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-10-25T22:34:09.469418+00:00 heroku[web.1]: Process exited with status 137
2017-10-25T22:34:09.484569+00:00 heroku[web.1]: State changed from starting to crashed

All others who have encountered this in various help sites solve their problem when binding to the Heroku $PORT, the same as how I do it:

#!venv/bin/python
import os
from app import app
port = int(os.environ.get('PORT', 33507))
app.run(host='0.0.0.0', port=port, debug=False)

And my Procfile:

web: python run.py runserver

Could it be that i’m running a virtual environment? Perhaps my app at 83.2M is too large? I’m kind of stuck here. Thanks in advance for your help!

esreli
  • 4,993
  • 2
  • 26
  • 40
  • did you check whether any dynos are running? – yash Oct 25 '17 at 23:04
  • I do try checking but isn't that part of the problem? I start the dyno, wait for a bit and then read in the logs `Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch` – esreli Oct 25 '17 at 23:06
  • try `port = int(os.environ.get('PORT', 5000))` . refer to https://stackoverflow.com/a/13714363/4410922 – yash Oct 25 '17 at 23:09
  • that has been tried with no success – esreli Oct 25 '17 at 23:10
  • replace the Procfile with `web: python ./run.py` – yash Oct 25 '17 at 23:11
  • I believe there might be a way to specify the port to assume by your web process. e.g In some languages or frameworks, you'd do: `PORT=5000 node server.js` or `rails s -p $PORT`. So, I'd probably say in your Procfile try `web: PORT=$PORT python run.py runserver` – oreoluwa Oct 25 '17 at 23:15
  • Neither of these techniques work. Might it be something else? Why does the console log: `2017-10-25T23:20:57.992995+00:00 app[web.1]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)` when I have specified it to be otherwise? (not 5000) – esreli Oct 25 '17 at 23:22
  • I don't believe you can statically assign a port to your heroku processes, that's dynamically assigned by Heroku and the contract is for you to bind to the `$PORT` variable provided. Common causes of the R10(according to this is: https://devcenter.heroku.com/articles/error-codes#r10-boot-timeout) is long startup time. How long does it take the app to startup locally? try to startup your app locally with the Procfile provided, since Heroku uses that and try to access it. You can try foreman(https://github.com/ddollar/foreman) or honcho(https://github.com/nickstenning/honcho) – oreoluwa Oct 26 '17 at 06:05

2 Answers2

3

Try changing your Procfile content like this:

web: gunicorn run:app -b "0.0.0.0:$PORT" -w 3

Where run is the name of the main application file denoting run.py

Bavya
  • 45
  • 7
0

Try changing:

  • Procfile content should be:

    web: python run.py
    
  • Port Number from 33507 to 8080

  • debug = True.
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135