Search code examples
pythonflaskherokugithub-pages

How to fix ' code=H14 desc="No web processes running" ' error on flask heroku app


I have just successfully deployed my python flask web app with Heroku via my github repo. Inside my repo i have: [templates(folder)/main python script/.DS_store/README.md/requirements.txt] note: requirements.txt contains (i found this on the web, not sure how it works):

*# This file is used by pip to install required python packages
# Usage: pip install -r requirements.txt
# Flask Framework
Flask==1.0.2
# Flask Packages
Flask-Login==0.4.0
Flask-Migrate==2.0.2
Flask-Script==2.0.5
Flask-SQLAlchemy==2.4.0
Flask-WTF==0.14.2
Flask-User==1.0.1.5
# Automated tests
pytest==3.0.5
pytest-cov==2.4.0*

when i go to my website https://cweste23.herokuapp.com/ I receive an 'application error' and it tells me to check the logs.

2020-12-08T07:50:51.196420+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cweste23.herokuapp.com
request_id=3af71da6-f891-480f-82eb-6fe50e462804 fwd="98.210.226.124" dyno= connect= service= status=503 bytes= protocol=https
2020-12-08T07:50:52.247386+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cweste23.herokuapp.com 
request_id=b8bae639-81f4-4a9b-823a-ee6d6ed6ffc3 fwd="98.210.226.124" dyno= connect= service= status=503 bytes= protocol=https

2020-12-08T07:53:55.531341+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cweste23.herokuapp.com 
request_id=ac8d1e20-428f-450a-8fa5-a5bf784c543f fwd="98.210.226.124" dyno= connect= service= status=503 bytes= protocol=https
2020-12-08T07:53:55.919575+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cweste23.herokuapp.com 
request_id=a07adad4-0fa9-4a07-9123-3ee204b4630c fwd="98.210.226.124" dyno= connect= service= status=503 bytes= protocol=https

2020-12-08T08:06:07.298661+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cweste23.herokuapp.com 
request_id=a48d6734-c0cd-4b0b-b478-dc5503036cbd fwd="98.210.226.124" dyno= connect= service= status=503 bytes= protocol=https
2020-12-08T08:06:08.727970+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cweste23.herokuapp.com 
request_id=ad64dfa9-f9ed-4e52-bdf0-99e8741b8f49 fwd="98.210.226.124" dyno= connect= service= status=503 bytes= protocol=https```

Solution

  • Usually it is either

    1. Heroku does not know which web process to start. This is fixed with Procfile.

    Procfile:

    web: python myServer.py
    
    1. Web process is not listening to right port. This is fixed by web server start 6 environment configuration

    Get the right port from PORT variable:

    port = int(os.environ.get('PORT', 5000))
    

    See: Deploying Flask app to Heroku