26đź‘Ť
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.
51đź‘Ť
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.
- [Django]-Django 1.5 custom User model error. "Manager isn't available; User has been swapped"
- [Django]-Django: Get list of model fields?
- [Django]-Update to Django 1.8 – AttributeError: django.test.TestCase has no attribute 'cls_atomics'
10đź‘Ť
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.
- [Django]-Make django admin to display no more than 100 characters in list results
- [Django]-Error: No module named psycopg2.extensions
- [Django]-Django: TypeError: 'tuple' object is not callable
2đź‘Ť
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)
- [Django]-Connect to a DB using psycopg2 without password
- [Django]-How do I perform HTML decoding/encoding using Python/Django?
- [Django]-Initial populating on Django Forms
1đź‘Ť
Yes, if you use quick launch EC2 option, you should add new HTTP rule (just as it appears on the list) to run a development server.
- [Django]-Is it possible to decorate include(…) in django urls with login_required?
- [Django]-Django – Unique list from QuerySet
- [Django]-Can't run the server on Django (connection refused)
1đź‘Ť
Adding a security group with the inbound rules as follows usually does the trick unless you have something else misconfigured. The port range specifies which port you want to allow incoming traffic on.
- HTTP access would need 80
- HTTP access over port 8000 would need 8000
- SSH to server would need 22
- HTTPS would need 443
- [Django]-Django authentication without a password
- [Django]-ImportError: No module named django_extensions
- [Django]-Django get the static files URL in view