7

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?

  • have u declared a web process in your proc file? for example: web: gunicorn_django -b 0.0.0.0:$PORT -w 9 -k gevent --max-requests 250 --preload settings – Philip Nuzhnyy Sep 07 '12 at 19:28

5 Answers5

9

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
Kirsten Jones
  • 2,681
  • 1
  • 17
  • 20
  • 1
    The Procfile was not needed. Heroku automatically detects a django app starts it for the default development server. – Madhuvanthi Ananth Jan 23 '12 at 05:49
  • As I said... if you have no Procfile and you're using the default web server, it will essentially do the above. But since you were having trouble I was suggesting you do it explicitly. – Kirsten Jones Jan 25 '12 at 17:13
  • What is the default server? Is there anything wrong with using it? – Mike Vella Aug 27 '13 at 21:52
  • @MikeVella you can't use it in production as it's not even multithreaded. [This guy](http://blog.etianen.com/blog/2014/01/19/gunicorn-heroku-django/) says to use Waitress. – Rob Grant Aug 12 '14 at 07:34
3

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.

aptwebapps
  • 1,866
  • 1
  • 13
  • 17
3

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.

Pstrazzulla
  • 455
  • 5
  • 6
  • This change Procfile but application is deployed by default from master branch where this changes don't apply. Run: heroku logs and there can be found Procfile config used. – pbaranski Jun 30 '14 at 20:43
1

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

Philip Nuzhnyy
  • 4,630
  • 1
  • 25
  • 17
0

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.

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
  • The runserver works fine locally. and the requirements.txt is present and settings.py too. The ProcFile is in the repo root and has the line: web: python madfb/manage.py runserver – Madhuvanthi Ananth Jan 19 '12 at 11:32
  • The first time I pushed to heroku I didn't have a `Procfile` and It wordked just fine. I added the `Procfile` after installing `gunicorn`. Also, keep in mind that cedar is still in beta – César Jan 19 '12 at 14:19
  • Cedar is beta technically, but far from the state in which it is unstable. A Procfile isn't required if you have a 'standard' setup such as Rails or Flask, Play! etc – Neil Middleton Jan 19 '12 at 14:27
  • I raised a ticket and heroku replied. looked like the django app directory was not checked in even though GIT said that the changes were pushed. I had sent them the check-in logs too. Now i did the whole thing from scratch, used a pre-compiled psycog2 and it works. The Procfile was not needed. Heroku automatically detects a django app starts it. – Madhuvanthi Ananth Jan 23 '12 at 05:47