Home > Enterprise >  Python Heroku shows R10 (Boot timeout) Error
Python Heroku shows R10 (Boot timeout) Error

Time:10-16

I'm trying to host a Flask app in Heroku, and I'm getting a boot timeout error (R10).
The other answers told me to use host="0.0.0.0" in run, but it's still not working.
I'm using Heroku CLI, Windows (CMD), Python 3.7.7.

Error

2021-10-10T18:05:14.522910 00:00 heroku[web.1]: Starting process with command `waitress-serve app:app`
2021-10-10T18:05:15.701238 00:00 app[web.1]: INFO:waitress:Serving on http://0.0.0.0:8080
2021-10-10T18:06:14.938492 00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-10-10T18:06:15.273888 00:00 heroku[web.1]: Stopping process with SIGKILL
2021-10-10T18:06:15.448673 00:00 heroku[web.1]: Process exited with status 137
2021-10-10T18:06:15.535916 00:00 heroku[web.1]: State changed from starting to crashed
2021-10-10T18:06:15.574210 00:00 heroku[web.1]: State changed from crashed to starting
2021-10-10T18:06:18.322384 00:00 heroku[web.1]: Starting process with command `waitress-serve app:app`
2021-10-10T18:06:19.508990 00:00 app[web.1]: INFO:waitress:Serving on http://0.0.0.0:8080
2021-10-10T18:06:35.678582 00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/favicon.ico" host=mhd-project.herokuapp.com request_id=5e553adf-0b86-4663-896f-cc948cac3e62 fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https
2021-10-10T18:07:03.746794 00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=mhd-project.herokuapp.com request_id=67e98e81-aedf-484c-af6f-61500d797daa fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https
2021-10-10T18:07:06.871218 00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=mhd-project.herokuapp.com request_id=5c7c269b-1261-4c99-b952-f559314f2460 fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https
2021-10-10T18:07:19.041046 00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-10-10T18:07:19.174484 00:00 heroku[web.1]: Stopping process with SIGKILL
2021-10-10T18:07:19.346300 00:00 heroku[web.1]: Process exited with status 137
2021-10-10T18:07:19.393363 00:00 heroku[web.1]: State changed from starting to crashed
2021-10-10T18:07:49.835669 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mhd-project.herokuapp.com request_id=a05bccea-a6e9-4f85-b9d6-0c9667ca2e50 fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https

App.py

from flask import Flask, render_template, request, g, flash, redirect, jsonify
import sqlite3
from flask_login import LoginManager, login_user, UserMixin, current_user, logout_user
from datetime import datetime,timedelta, date

...

if __name__ == "__main__":
      app.run(host='0.0.0.0')

requirements.txt

click==7.1.2
Jinja2==2.11.2
itsdangerous==1.1.0
Werkzeug==1.0.1
Flask==1.1.2
SQLAlchemy==1.3.22
Flask-SQLAlchemy==2.4.4
waitress==2.0.0
Flask-Login==0.5.0

Procfile

web: waitress-serve app:app

CodePudding user response:

You need get the port config from Heroku, and use it on your app:

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

Reference: https://blog.heroku.com/python_and_django

CodePudding user response:

Procfile

web: bundle exec thin start -p $PORT

this fixed it for me using a docker container with spring boot

got help from: Heroku Boot Timeout (Error R10)

  • Related