Curl amazon EC2实例

Curl amazon EC2实例,curl,amazon-web-services,amazon-ec2,Curl,Amazon Web Services,Amazon Ec2,我有一个web服务器在端口3000的Ubuntu Amazon EC2实例上运行15.0.0.10是此EC2实例的私有ip 在我使用ssh连接到此实例并运行以下命令curl localhost:3000/index.html之后,它将返回index.html页面的html源代码 但是当我运行curl15.0.0.10:3000/index.html时,它会说: curl: (7) couldn't connect to host 为什么会这样 如何使第二个命令也返回内容 如果需要通过寻址实例的

我有一个web服务器在端口3000的Ubuntu Amazon EC2实例上运行
15.0.0.10
是此EC2实例的私有ip

在我使用ssh连接到此实例并运行以下命令
curl localhost:3000/index.html
之后,它将返回index.html页面的html源代码

但是当我运行curl15.0.0.10:3000/index.html时,它会说:

curl: (7) couldn't connect to host
  • 为什么会这样
  • 如何使第二个命令也返回内容

  • 如果需要通过寻址实例的anyIP来访问服务器,则需要确保服务器在0.0.0.0上运行


    如果您已经在localhost(127.0.0.1)上启动了它,那么该行为是预期的。您可以停止服务器并重新启动它以绑定到0.0.0.0:3000。事情应该会成功。

    是的。在ifconfig输出的eth0中,
    inet addr:15.0.0.10