简体   繁体   English

无法访问 AWS EC2 实例

[英]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:即使将入站规则设置为允许所有流量,我也无法访问 AWS AMI 实例:

在此处输入图像描述

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.如果答案是操作系统命令行访问,那么您应该尝试使用 SSH 应用程序。 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?尝试首先访问操作系统,使用 SSH(假设这是一台 linux 机器),我假设你应该有你的用户名和密码?

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 .EC2 仪表板中,单击Instances (running) ,然后单击Instance ID Click on the VPC ID for that instance and then on Main network ACL .单击该实例的VPC ID ,然后单击Main network ACL Click now on the Network ACL ID and confirm your Inbound rules, Outbound rules and Subnet associations.现在单击网络 ACL ID并确认您的入站规则、出站规则和子网关联。 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.你没有这么说,但我想你有 SSH 访问实例。 Make sure HTTP and HTTPS services are running and listening for connections on the interface IP address and not on 127.0.0.1;确保 HTTP 和 HTTPS 服务正在运行并侦听接口 IP 地址而不是 127.0.0.1 上的连接; something like this:像这样的东西: 在此处输入图像描述

  4. Make sure IPtables is not blocking access.确保 IPtables 没有阻止访问。 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运行 tcpdump 并在端口 80 或 443 上查找流量在此处输入图像描述

  6. If still not working... make sure you are accessing the right IP address;如果仍然无法正常工作...确保您访问的是正确的 IP 地址; If you're not using an elastic IP and your restarted the instance it will have a new public IP address.如果您没有使用弹性 IP 并且您重新启动了实例,它将有一个新的公共 IP 地址。

If this is a NAT instance, you must stop source / destination checking.如果这是一个 NAT 实例,您必须停止源/目标检查。 A NAT instance must be able to send and receive traffic when the source or destination is not itself.当源或目标不是自身时,NAT 实例必须能够发送和接收流量。

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

Is your EC2 on a VPC that permits public IP addresses?您的 EC2 是否位于允许公共 IP 地址的 VPC 上? This can commonly happen when you have accidentally attached the EC2 to a private VPC.当您不小心将 EC2 附加到私有 VPC 时,通常会发生这种情况。

If this is the case make an AMI of the EC2 and re-create it on the public VPC.如果是这种情况,请创建 EC2 的 AMI 并在公共 VPC 上重新创建它。

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

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