flaskherokuwaitress

How to deploy Flask app using waitress and heroku?


I have deployed Flask app successfully but I am getting application error when I click on the herokuapp link. When I checked logs it shows something like this

2022-01-03T12:52:35.000000+00:00 app[api]: Build started by user
2022-01-03T12:53:02.508102+00:00 app[api]: Deploy 8a785469 by user 
2022-01-03T12:53:02.508102+00:00 app[api]: Release v4 created by user
2022-01-03T12:53:03.794631+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-03T12:53:07.748702+00:00 heroku[web.1]: Starting process with command `waitress-serve --call flaskr:create_app`
2022-01-03T12:53:09.003519+00:00 app[web.1]: INFO:waitress:Serving on http://0.0.0.0:8080
2022-01-03T12:53:12.000000+00:00 app[api]: Build succeeded
2022-01-03T12:54:08.177780+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-01-03T12:54:08.255635+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-01-03T12:54:08.406812+00:00 heroku[web.1]: Process exited with status 137

I have also used heroku ps:scale web=1

My Procfile includes:

web: waitress-serve --call flaskr:create_app 
 

Solution

  • You must provide the port to bind to (you cannot use the default 8080)

    web: waitress-serve --port=$PORT --call 'flaskr:create_app'