简体   繁体   English

无法访问托管在 AWS EC2 实例上的我的 Django 页面

[英]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我无法在浏览器中的 EC2 实例 (host2) 上访问我的 Django 应用程序,方法是输入其公共 DNS 名称和端口号: 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我正在使用我的其他 EC2 实例 (host1) 正在使用的同一个安全组,它工作得很好(我在这个实例上托管的其他 Django 应用程序工作得很好),HTTP/TCP 在端口上的 0.0.0.0/0 上打开8000
  2. I started my Django project this way: ./manage.py runserver 0.0.0.0:8000我以这种方式开始了我的 Django 项目: ./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']我已将主机添加到我的ALLOWED_HOSTS文件中,该文件现在具有以下内容: 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.当我 ssh 进入这个实例时,我能够curl localhost:8000返回 200 和 Django 默认 HTML 页面。
  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. 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. host1 和 host2 在同一个 AZ 中使用完全相同的子网、VPC、SG、AMI。
  7. both host1 and host2 are running on AMI Ubuntu 18.04 LTS host1 和 host2 都在 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...我不知道为什么会这样……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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