Reputation: 213
I have a python web app that I can successfully run on my local machine with this command
python run.py
I have successfully deployed the code to Heroku, but when I go to my application URL I get this error message that says
Application error. An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Looking at the log tails yields
heroku logs --tail ✘ 2
› Error: Missing required flag: › -a, --app APP app to run command against
My Procfile contains
web: python --app monte-carlo-retirement run.py
where monte-carlo-retirement is the name of my app
Upvotes: 0
Views: 639
Reputation: 137170
You're conflating two things.
The error about a missing -a
or --app
argument is related to running the heroku
CLI locally. Instead of just heroku logs --tail
, try heroku logs --app=monte-carlo-retirement --tail
. This should give you useful log output.
See also How does `heroku config` know what app to use? and How to avoid the --app option with heroku CLI?.
Your Procfile
doesn't need that argument. You deploy your code to a particular app, so there is no confusion about what app it applies to. Furthermore, you are giving that argument to python
where it is meaningless.
Take it out of your Procfile
:
web: python run.py
Then commit and redeploy.
Now, you haven't shown us what is in your run.py
, but this would be a weird way to run it in production. A more common approach would be to use something like Gunicorn.
Install it locally and add it to your requirements.txt
(if you are using pip
) or Pipfile
/ Pipfile.lock
(if you are using Pipenv). Then modify your Procfile
again to something like
web: gunicorn run:app
where app
is the name of the Flask object in run.py
.
Upvotes: 1