Connecting to EC2 Django development Server

You probably don't have port 8000 open on the firewall. Check which security group your instance is running (probably "default") and check the rules it is running. You will probably find that port 8000 is not listed.


I was having the same problem. But I was running RHEL on EC2. Besides from adding a rule to security group, I had to manually add a port to firewalld.

firewall-cmd --permanent --add-port=8000/tcp
firewall-cmd --reload

That worked for me! (Although no idea why I had to do that)


1) You need to make sure port 8000 is added as a Custom TCP Rule into your Security Group list of inbound ports

2) Odds are that the IP that you see listed on your AWS Console, which is associated to your instance is a PUBLIC IP OR a PUBLIC Domain Name(i.e. ec2-###-##-##-##.compute-1.amazonaws.com or 174.101.122.132) that Amazon assigns.

2.1) If it is a public IP, then your instance has no way of knowing what the Public IP assigned to it is, rather it will only know the its assigned Local IP.

2.2) To get your Local IP on a Linux System, type:

    $ ifconfig

Then look at the eth0 Data and you'll see an IP next to "inet addr" of the format xxx.xxx.xxx.xxx (e.g. 10.10.12.135) This is your Local IP

3) To successfully runserver you can do one of the following two:

    $ python manage.py runserver <LOCAL IP>:8000
    or
    $ python manage.py runserver 0.0.0.0:8000

** Option Two also works great as Ernest Ezis mentioned in his answer. EDIT : From The Django Book : "The IP address 0.0.0.0 tells the server to listen on any network interface"

** My theory of Public IP could be wrong, since I'm not sure how Amazon assigns IPs. I'd appreciate being corrected.


Using an ec-2 instance with Ubuntu, I found that specifying 0.0.0.0:8000 worked:

$python manage.py runserver 0.0.0.0:8000  

Of course 8000 does need to be opened for TCP in your security group settings.