简体   繁体   English

无法使用cURL连接到AWS EC2实例

[英]Can't connect to an AWS EC2 instance with cURL

Can anyone tell me why can't I connect to an AWS EC2 instance? 任何人都可以告诉我为什么我不能连接到AWS EC2实例?

I am using cURL to connect like this: 我正在使用cURL这样连接:

curl ec2-54-xxx-xx-xxx.eu-west-1.compute.amazonaws.com

But I am getting the following error: 但是我收到以下错误:

curl: (7) couldn't connect to host

Can anyone tell me what might be wrong? 谁能告诉我可能出错的是什么? I haven't previously worked with AWS. 我之前没有使用过AWS。

This could be many things: 这可能是很多事情:

  1. Review the AWS Security Groups . 查看AWS安全组 You probably need to add an incoming traffic exception rule for port 80 in the Security Group that's attached to your instance. 您可能需要在附加到实例的安全组中为端口80添加传入流量例外规则。 For more information refer to the documentation . 有关更多信息, 请参阅文档

  2. If your EC2 instance is in a VPC, you need to make sure networking has been set up properly with an Internet Gateway and proper Routing Table rules. 如果您的EC2实例位于VPC中,则需要确保已使用Internet网关和正确的路由表规则正确设置了网络。 For reference, there is a nice example of a typical VPC setup here . 作为参考,有一个典型的VPC设置的一个很好的例子在这里

  3. Additionally, if the above don't solve the issue, check the EC2 instance's OS firewall rules and that the HTTP server is running. 此外,如果上述方法无法解决问题,请检查EC2实例的操作系统防火墙规则以及HTTP服务器是否正在运行。

Check for the firewall on your server which is blocking the connection. 检查服务器上阻止连接的防火墙。 Are you able to curl any other website 你能卷曲任何其他网站吗?

If you are curling an FTP URL then you may need to set the FTP Passive port range and open the range in your Security group. 如果您正在卷曲FTP URL,则可能需要设置FTP Passive端口范围并在安全组中打开范围。

Credit: Setting up FTP on Amazon Cloud Server 信用: 在Amazon Cloud Server上设置FTP

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

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