When I deploy my Django app to Heroku, in the console (heroku logs --tail -a george-paintings) I see an error:
2021-04-15T15:14:42.109272+00:00 app[web.1]: Error: No application module specified.
2021-04-15T15:14:42.161597+00:00 heroku[web.1]: Process exited with status 1
2021-04-15T15:14:42.290903+00:00 heroku[web.1]: State changed from starting to crashed
But I can't figure out what particular went wrong. My Procfile looks like this
web: gunicorn --pythonpath application.george_paintings.george_paintings.wsgi --log-file - --log-level debug
Where can I find more info about my error?
I suspect there's nothing more to see. A good first step would be to try running heroku local to see if you are having the same problem on your development machine. This will use your Procfile whereas if you are running via python manage.py migrate or similar your Procfile will not be used.
The error gives a good hint, though:
app[web.1]: Error: No application module specified.
Gunicorn expects an application module name as a command-line argument. I suspect you intend application.george_paintings.george_paintings.wsgi to be interpreted as your application module, but it's getting swallowed up as an argument to --pythonpath:
gunicorn --pythonpath application.george_paintings.george_paintings.wsgi #...
You shouldn't need to explicitly provide a PYTHONPATH. Try removing that argument from your Procfile entirely:
gunicorn application.george_paintings.george_paintings.wsgi --log-file - --log-level debug
If this works locally with heroku local, commit the change and redeploy.
If not, take a look at your directory structure. application.george_paintings.george_paintings.wsgi is a bit of a weird module name for a Django project. Usually you'd just need something like george_paintings.wsgi (indicating that Gunicorn should use the Python module it finds at george_paintings/wsgi.py as its entry point).
Related
I am trying the getting your first django app in heroku. There it is mentioned 'Use a Procfile, in the root directory of your application, to explicitly declare what command should be executed to start your app'.
The command is "web: gunicorn gettingstarted.wsgi --log-file -"
And the error I see is 'web:' is not recognised as an internal or external command.
Please help me out.
You're supposed to put that command into a file called Procfile, not type it into the terminal.
My Problem:
When using gunicorn as my WSGI HTTP server, foreman fails to find the Django (wsgi?) application.
Application Structure:
In my Django application, I have things structured like this:
<git_repository_root>/
<django_project_root>/
<configuration_root>/
The <git_repository_root> contains the project management and deployment related things (requirements.txt, Procfile, fabfile.py, etc.)
The <django_project_root> contains my Django apps and application logic.
Finally, the <configuration_root> contains my settings.py and wsgi.py.
What I have tried:
My Procfile should look like this (according to the Heroku Docs):
web: gunicorn myapp.wsgi
When running foreman start with this project layout, I get an error:
ImportError: Import by filename is not supported.
What works:
If I move my Procfile from <git_repository_root> to <git_repository_root> it works locally. After pushing to Heroku (note: Heroku sees <git_repository_root>) I can't scale any workers / add processes. I get the following:
Scaling web dynos... failed
! No such process type web defined in Procfile.
I believe I want Procfile in my <git_repository_root> anyway though - so why isn't it working? I also tried changing the Procfile to:
web: gunicorn myapp/myapp.wsgi
but no luck. Any help would be much appreciated!
Treat the entry in your Procfile like a bash command. You can cd into your <django_project_root> and then run the server.
For example, your Procfile (which should be in your <git_repository_root>) might look something like this:
web: cd <django_project_root> && gunicorn
--env DJANGO_SETTINGS_MODULE=<configuration_root>.settings
<configuration_root>.wsgi
Move your Procfile back to <git_repository_root> and use:
web: gunicorn <django_project_root>.myapp:myapp
replacing the final "myapp" with your app's class name, presumably it is indeed "myapp".
... and read the error message: it is telling you that you can't import your worker class (app) by filename (myapp.wsgi), so of course saying dirname/myapp.wsgi won't work as well. You need a Python module:class syntax.
Trying to upload my Django app to Heroku and getting:
2013-05-22T23:04:55.687398+00:00 heroku[web.1]: Starting process with command `gunicorn main.wsgi`
2013-05-22T23:04:56.508882+00:00 app[web.1]: bash: gunicorn: command not found
2013-05-22T23:04:57.958215+00:00 heroku[web.1]: State changed from starting to crashed
2013-05-22T23:04:57.941729+00:00 heroku[web.1]: Process exited with status 127
2013-05-22T23:05:06.019313+00:00 heroku[web.1]: Error R99 (Platform error) -> Failed to launch the dyno within 10 seconds
2013-05-22T23:05:06.019520+00:00 heroku[web.1]: Stopping process with SIGKILL
I know gunicorn is in requirements.txt and have pushed that so it should all work. The app runs with foreman.
Does anyone have any suggestions as to what might be wrong?
Sometimes, Heroku's buildpacks just fail in completely strange ways.
Try this:
heroku run pip install gunicorn
See what happens.
I was accidentally pushing a .bash_profile which had got in my project and was setting the PATH causing havoc on the heroku stack.
I just did what Jack Shedd said, and it works fine for me.
Run:
herouku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python
Then, do a commit in your repository. Finally, do:
git push heroku master
According to the Heroku site when I get error H14 "No Web Processes Running" it's because I need to scale up dynos by:
heroku ps:scale web=1
However, when I do that I get the following error:
Scaling web processes... failed
! No such type as web
Does anyone know how to fix this? I want to get my site back up!
When I run heroku ps I see nothing.
UPDATE: It's not detecting my Procfile. I don't have a Procfile explicitly and didn't use one before... is it absolutely necessary?
I ran into this recently as well, my web was working fine without any Procfile, until recently...
My fix was simply to add a Procfile as follows:
web: python manage.py runserver 0.0.0.0:$PORT --noreload
Then push to heroku.
For Heroku you need to add a Procfile.
add a Procfile on same level like your manage.py file. It should be in your root directory. Be sure that you create a Procfile not a Procfile.txt or else just Procfile
in your Procfile add:
web: gunicorn projectname.wsgi
add in your requirements.txt gunicorn
gunicorn==20.0.4
If you activate automatic deploy you can try it again.
If you can remove the app, remove it and deploy it again.
Followed the "Getting started with Django on heroku/ceadar" guide to the letter and FINALLY managed to sort out some issues on app deployment
Successfully installed django psycopg2
Cleaning up...
Discovering process types
Procfile declares types -> (none)
Compiled slug size is 8.0MB
Launching... done, v4
http://<watever>.herokuapp.com deployed to Heroku
and the guide says the webserver should be up. but heroku ps shows no processes, and obviously the page doesnt load.
tail of the heroku log:
2012-01-19T10:28:29+00:00 heroku[web.1]: State changed from created to down
2012-01-19T10:28:30+00:00 heroku[web.1]: State changed from down to created
2012-01-19T10:28:32+00:00 heroku[slugc]: Slug compilation finished
2012-01-19T10:30:32+00:00 heroku[router]: Error H99 (Platform error) -> GET <watever>
.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
(venv) C:\Python27\facebook\venv\myapp>heroku ps
Process State Command
------- ----- -------
should I be starting the webserver explicitly? wat am I doing wrong?
The Procfile I use for my django/heroku instance looks like this:
web: python hellodjango/manage.py runserver "0.0.0.0:$PORT"
As has been mentioned, if you have no Procfile and you're using the default webserver, it will essentially do the above - but try being explicit. You can try running it from the heroku console instead, to see what (if any) errors it gets:
heroku run python hellodjango/manage.py runserver
I just ran into the same problem, although I don't know if it was for the same reason or not.
While executing this command from the tutorial:
django-admin.py startproject hellodjango .
I changed the name of the app to something else (not just in this command, of course), but I omitted the '.' at the end. This caused the script to create an app inside a directory of the same name rather right in the directory I was in and that caused Heroku's server-side script to fail to detect the app as a Django app.
I ran into this problem as well. Make sure your Procfile looks correct by running...
$heroku run bash
to open a terminal with access to heroku. And then...
$cat Procfile
This will show you what is actually in your Procfile. The first line (in my local file) in mine wasn't being read for some reason. Then, I had a "}" appended to my file. I was creating my file in TextEdit on a Mac - should have been using SublimeText or another text editor. You can also call
$echo "web: gunicorn hello:app" >> Procfile
Or whatever you want your Procfile to say. This will change your Procfile to whatever you echo.
I've been struggling with Django on Heroku for some time and decided to put together a very opinionated but functioning bootstrap. I hope it can help others along the road: https://github.com/callmephilip/django-heroku-bootstrap
The key is here:
Procfile declares types -> (none)
Heroku doesn't know how to run your application. I assume python hellodjango/manage.py runserver works locally for you? If so, Heroku should be able to pick this up.
Also check that you have a requirements.txt in the repo root, and a settings.py in one of your project subdirectories.