简体   繁体   中英

Cannot access my Django page hosted on AWS EC2 instance

I cannot access my Django app on an EC2 instance (host2) in my browser by typing its public DNS name with port number: ec2-public-dns-of-this-instance.compute-1.amazonaws.com:8000

  1. I'm using the same Security Group that my other EC2 instance (host1) is using which is working just fine (my other Django app hosted on this instance works perfectly fine), with HTTP/TCP open on 0.0.0.0/0 on port 8000
  2. I started my Django project this way: ./manage.py runserver 0.0.0.0:8000
  3. I've added hosts into my ALLOWED_HOSTS file which has these now: ALLOWED_HOSTS = ['*', '127.0.0.1', 'ec2-public-dns-of-this-instance.compute-1.amazonaws.com', '0.0.0.0', 'localhost']
  4. I was able to curl localhost:8000 which returned me 200 and Django default HTML page when I'm ssh'ed into this instance.
  5. I was able to curl ec2-public-dns-of-this-instance.compute-1.amazonaws.com:8000 which also returned me 200 and Django default HTML page when I'm ssh'ed into this instance.
  6. both host1 and host2 are using the exactly the same subnet, VPC, SG, AMI, in the same AZ.
  7. both host1 and host2 are running on AMI Ubuntu 18.04 LTS

Any ideas how to fix this would be greatly appreciated!

Interestingly, it started working three hours later. I didn't change anything and all things remain the same as I described above. I have no clue why this is the case...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM