Beginner question here. Its probably obvious to someone who does this stuff all the time. But I'm having difficulty setting up django running on an EC2 bitnami instance.

I setup my server and I'm able to log in. Just to test this I setup the polls example. Below are the commands I executed to get this running.


  • What am I doing wrong here?
  • How do I get my basic polls page to show?
  • Also, is there any best practices I should follow to configure a live server?

Any step-by-steps are greatly appreciated.


$ cd /opt/bitnami/projects/Project  #directory already exists
$ sudo python manage.py startapp polls
$ sudo chown -R bitnami * # tired of doing sudo.. Good move or not?
$ vim polls/models.py  # matches the example
$ vim polls/views.py  #see below
$ vim urls.py   # added: (r'^polls/$', 'polls.views.index'),
$ vim settings.py  #added polls
$ python manage.py syncdb  # tables created successfully
$ python manage.py runserver  # server started

# Now I open my browser and go to:  http://10.206.xxx.yyy:8000/polls/
# also tried ports 8080 and 80
# Error: unable to connect


# Create your views here.
from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the poll index.")

I also tried comments stated below without success.

Port 80

$ sudo python manage.py runserver
Django version 1.3, using settings 'Project.settings'
Development server is running at
Quit the server with CONTROL-C.
Error: That port is already in use.

Port 8000

$ python manage.py runserver
#also tried python manage runserver 10.206.xxx.yyy:8000 (same results)
Django version 1.3, using settings 'Project.settings'
Development server is running at http://10.206.xxx.yyy:8000/

in browser:  http://10.206.xxx.yyy:8000
result:  Firefox can't establish a connection to the server at 10.206.xxx.yyy:8000.
in browser:  http://10.206.xxx.yyy:8000/polls
result:  same Firefox can't establish a connection


$ netstat -aon
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer
tcp6       0      0 :::80                   :::*                    LISTEN      off (0.00/0/0)
# I don't know what this means exactly and why I can't see this server from the browser

Any ideas why its not working?

migrated from stackoverflow.com Nov 3 '11 at 12:48

This question came from our site for professional and enthusiast programmers.


If you use the vanilla runserver it connects to localhost ( Which means you'd only be able to access it within the actual server instance. To get it to connect on it's actual IP, you can use:

$ python manage.py runserver

You can use another port, if you like, but if you want to connect it on port 80, you will need to sudo:

$ sudo python manage.py runserver

Note: It may not be obvious, so just in case: the part is intended. It means essentially connect to the assigned IP address for the server. You can use the actual IP address instead, but I find this easier: you don't have to remember or lookup up the server's IP.

FWIW: This also works brilliantly for browser testing when you have a VM setup for bridged networking. The VM gets its own IP on the LAN with bridged networking. So, for example, with a linux guest running on a Windows host, you can load up runserver this way in your VM, go over and open up IE on your Windows host, and point it to the VM's IP address.

  • sudo python manage.py runserver gives Error: That port is already in use. How do I figure out what's on port 80? Also, if port 80 was open, wouldn't I have seen something when I did my browser test earlier? – codingJoe Nov 2 '11 at 22:22
  • see above for results based on this suggestion. – codingJoe Nov 2 '11 at 22:43

It seems that you are using BitNami DjangoStack. The Apache server included in the stack should be running and that is why you cannot start the server in port 80. If you are just developing and you want to use the django server you can stop Apache server.

sudo /opt/bitnami/ctlscript.sh stop apache

Also notice that if you want to use a different port you may need to open it in your amazon security group.


Both the answers are right, but I think your whole approach isn't ideal. The django development server is good for some things, but actually running out in the cloud isn't necessarily one of them. I would suggest actually just using Apache, which the bitnami djangostack makes pretty easy for you.

So you'd do the same thing up until you run runserver, at which point instead you would edit the appropriate apache config file that has django stuff, which I think is called django.conf:

WSGIScriptAlias /django “/opt/bitnami/apps/django/conf/django.wsgi”

Or whatever is right (it might be right already).

Then go edit that file to make sure things point to the right place:

os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘myproject.settings’

Then restart apache. Now when you hit port 80, it should invoke your django code. One thing you can do is make sure DEBUG is set to True in your settings.py file, so that you can disambiguate problem with invoking django and problems with your actual django code or config.

  • Two related questions by another newbie: how do you restart apache? And when do you need to restart it -- every time the project is modified, just once, or some other conditions? – Abe Nov 10 '11 at 18:47
  • In bitnami, there's something called ctlscript, run that with arguments "restart apache" and it will do it. You can also just do it directly, see the apache documentation for help. You need to do it any time you change the apache configuration or any of your code, but not for html or template files. – Dave Orr Nov 21 '11 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy