Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web process failed to bind to $PORT within 60 seconds of launch

Can someone explain to me this error message on Heroku? App works fine locally but has never succeeded online

heroku[slug-compiler]: Slug compilation started
heroku[slug-compiler]: Slug compilation finished
heroku[web.1]: State changed from crashed to starting
heroku[web.1]: Starting process with command `python app.py ${PORT}`
app[web.1]:  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

The app itself is not very complicated

from flask import Flask, render_template
app = Flask(__name__, static_folder='static') 

@app.route('/')
def hello_world():
    return render_template('index.html')

if __name__ == '__main__':
    from os import environ
    app.run(debug=False, port=environ.get("PORT", 5000))
like image 662
john mangual Avatar asked Apr 18 '16 00:04

john mangual


1 Answers

You need to specify host='0.0.0.0' in app.run(). Unless told otherwise, Flask binds to "localhost", which means it won't bind to an externally visible interface.

See Flask - configure dev server to be visible across the network

like image 120
bimsapi Avatar answered Nov 01 '22 19:11

bimsapi