Search code examples
pythonflaskheroku

App deployed on heroku but not opening.Have used python


this is the error i am getting.

this is the 3 time i am getting same error while deployment. I also checked the logs. The log file contents are:

please help

2021-03-23T19:58:37.705318+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/%20deployed%20to%20Heroku" host=co2-emission-pre-diction.herokuapp.com request_id=c3e2c6e3-0762-46f5-b2fd-99149f594594 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:58:38.517056+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=co2-emission-pre-diction.herokuapp.com request_id=dea037a8-d4ee-429f-a31a-595d79c430cb fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:58:45.302966+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=co2-emission-pre-diction.herokuapp.com request_id=f4584f03-44f1-4117-aabb-6d7e6d888a2e fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:58:46.898144+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=co2-emission-pre-diction.herokuapp.com request_id=fc38ae35-5afb-4a41-a8fb-a96574232c7d fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:59:18.687973+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=co2-emission-pre-diction.herokuapp.com request_id=9f7e3d6f-7356-4994-b8d4-0f9b1656b679 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:59:19.522940+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=co2-emission-pre-diction.herokuapp.com request_id=926260ee-1f96-4ed6-90f0-e62bc10e7f13 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:59:55.796315+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=co2-emission-pre-diction.herokuapp.com request_id=9e4a1ad9-c826-430a-837d-6c3bb1623629 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T19:59:56.428470+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=co2-emission-pre-diction.herokuapp.com request_id=36e2296a-8364-42a3-b647-65136ea59972 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T20:01:35.260787+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=co2-emission-pre-diction.herokuapp.com request_id=e0070481-0492-4b10-975b-27ddbb086646 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T20:01:36.411104+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=co2-emission-pre-diction.herokuapp.com request_id=0a59ff26-3a8d-45d4-a3b6-030f8126fc8b fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T20:04:08.260298+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=co2-emission-pre-diction.herokuapp.com request_id=e9e66103-fd75-4f88-9a8b-728379b146a4 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https
2021-03-23T20:04:09.542606+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=co2-emission-pre-diction.herokuapp.com request_id=88e2ee70-4247-4afa-9d9f-ebce57af9533 fwd="157.45.119.41" dyno= connect= service= status=503 bytes= protocol=https

Solution

  • Ensure you have Procfile in your top-level directory.

    Heroku uses the Postgres database, and for that it requires these packages to be installed:

    • gunicorn
    • psycopg2

    You can do that by running:

    (venv)$ pip3 install psycopg2 gunicorn
    

    Remember to update your requirements.txt file to include these two packages because Heroku will build your application using the dependencies in the file.

    Update Procfile as follows:

    web: flask db upgrade; gunicorn <your-entry-to-the-app-file>:app
    
    # You can remove flask db upgrade if you don't need it
    # Entry file is set in FLASK_APP variable
    

    Set your FLASK_APP variable

    (venv)$ heroku config:set FLASK_APP=app.py
    

    Commit your changes, and a remote Heroku repository and push to Heroku

    (venv)$ git commit -m 'Add changes for Heroku deployment'
    (venv)$ heroku git:remote -a <name-of-your-heroku-app>
    (venv)$ git push heroku master
    
    # Output
    Enumerating objects: 1170, done.
    Counting objects: 100% (1170/1170), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (391/391), done.
    Writing objects: 100% (1170/1170), 691.88 KiB | 43.24 MiB/s, done.
    Total 1170 (delta 760), reused 1148 (delta 750)
    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote: -----> Python app detected
    remote: -----> Installing python-3.6.12
    remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
    remote: -----> Installing SQLite3
    remote: -----> Installing requirements with pip
    # ...
    remote: -----> Discovering process types
    remote:        Procfile declares types -> web
    remote: 
    remote: -----> Compressing...
    remote:        Done: 59.3M
    remote: -----> Launching...
    remote:        Released v18
    remote:        https://your-app-name.herokuapp.com/ deployed to Heroku
    remote: 
    remote: Verifying deploy... done.
    To https://git.heroku.com/your-app-name.git
     * [new branch]      master -> master