Skip to content Skip to sidebar Skip to footer

Proper Format Of Procfile For Flask App On Heroku

I'm trying to deploy a flask app on heroku. I've gotten to the point where the app builds and deploys, but when I try to go to the URL, the app times out with the following error.

Solution 1:

Most likely your flask app isn't answering on the port and interface the Heroku expects. By default, Flask only listens on 127.0.0.1, and I think on port 5000. Heroku passes your app a PORT environment variable and you'd need to tell Flask to listen on all interfaces.

But there are reasons other than performance you want to avoid Flask's default debug server for production code. It's got memory leaks, there are security implications, and really ... just don't do it. Add gunicorn to your requirements.txt and use that.

But if you must use the Flask test/debug server, change your app.run() call to something like this:

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

Post a Comment for "Proper Format Of Procfile For Flask App On Heroku"