简体   繁体   中英

Can't connect to an AWS EC2 instance with cURL

Can anyone tell me why can't I connect to an AWS EC2 instance?

I am using cURL to connect like this:

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.

This could be many things:

  1. Review the AWS Security Groups . You probably need to add an incoming traffic exception rule for port 80 in the Security Group that's attached to your instance. 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. For reference, there is a nice example of a typical VPC setup here .

  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.

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.

Credit: Setting up FTP on Amazon Cloud Server

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