简体   繁体   中英

Unable to access AWS EC2 instance

I am unable to access an AWS AMI instance even after setting the inbound rules to allow all traffic:

在此处输入图像描述

I get this error:

This site can’t be reached
X.XX.XXX.XX refused to connect.
Try:

Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

How can I fix this?

"This site cant be reached" Connection refused makes me think your issue is at the application level. are you trying to browse to something, can you give more info on what app you are using to get this message back?

When you say you are 'trying to access', what are you trying to access exactly? if the answer is OS commandline access, then you should be trying to use SSH the application. If you are trying to get a website to render, did you set that up properly yet? What application and port are you requesting?

Try to access the OS first, with SSH (assuming this is a linux machine), you should have your username and password I assume?

I would:

  1. Make sure your inbound rules are as you shown and that your outbound rules do allow all traffic to exit.

  2. In the EC2 Dashboard click on the Instances (running) and then click on the Instance ID . Click on the VPC ID for that instance and then on Main network ACL . Click now on the Network ACL ID and confirm your Inbound rules, Outbound rules and Subnet associations. Make sure nothing here is blocking access. By default the Inbound and Outbound rules will allow all traffic and all subnets will be there.

  3. You do not say so, but I imagine you have SSH access to the instance. Make sure HTTP and HTTPS services are running and listening for connections on the interface IP address and not on 127.0.0.1; something like this: 在此处输入图像描述

  4. Make sure IPtables is not blocking access. If you have existing rules you may want to clear them so that they look like: 在此处输入图像描述

  5. Run tcpdump and look for traffic on ports 80 or 443在此处输入图像描述

  6. If still not working... make sure you are accessing the right IP address; If you're not using an elastic IP and your restarted the instance it will have a new public IP address.

If this is a NAT instance, you must stop source / destination checking. A NAT instance must be able to send and receive traffic when the source or destination is not itself.

来源/目的地检查 停止检查

Is your EC2 on a VPC that permits public IP addresses? This can commonly happen when you have accidentally attached the EC2 to a private VPC.

If this is the case make an AMI of the EC2 and re-create it on the public VPC.

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