I am trying to deploy my first flask application in heroku. Followed steps exactly as mentioned in heroku documentation. But It is throwing Application error as shown below
2021-07-18T12:55:34.315320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=eflask-simple-app.herokuapp.com request_id=30d3a699-6f05-4783-a5f5-40c9717af881 fwd="117.213.244.13" dyno= connect= service= status=503 bytes= protocol=https
Project Structure
app main.py Pipfile Pipfile.lock Procfile requirements.txt runtime.txt wsgi.py
wsgi.py file
from app.main import app import os port = int(os.environ.get("PORT", 5000)) if __name__ == "__main__": app.run(host='0.0.0.0', port=port, debug=True)
Procfile
web: gunicorn --bind 127.0.0.1:5000 wsgi:app
app/main.py
from flask import Flask app = Flask(__name__) @app.route("/") def home_view(): return "<h1>Welcome to Flask</h1>"
requirements.txt
click==8.0.1 colorama==0.4.4 Flask==2.0.1 gunicorn==20.1.0 itsdangerous==2.0.1 Jinja2==3.0.1 MarkupSafe==2.0.1 Werkzeug==2.0.1
runtime.txt
python-3.9.6
Advertisement
Answer
Welcome to Stackoverflow @vishnuvreddy
Since you are deciding port using
port = int(os.environ.get("PORT", 5000))
and mentioned --bind
in Procfile as below
web: gunicorn --bind 127.0.0.1:5000 wsgi:app
conflict each other.
Solution
Change Procfile to
web: gunicorn wsgi:app