ping to an EC2 instance times out, but SSH and the website work
Request timed out.Short answer
Ping is ICMP traffic, and a security group that allows SSH or HTTP does not allow it. Add an inbound ICMP Echo Request rule for your address. Use an ICMPv6 rule for ping6, and an outbound rule if the instance is the one pinging. Firewalls on the path can also drop ICMP.
Fix it fast
1Find out which cause you have
List the rules of the instance's security group and look for an ICMP line. If there is none, the first cause below is yours.
aws ec2 describe-security-groups --group-ids sg-1234567890abcdef02Match what you see, then jump to its fix
- 1
ping times out while TCP services on the same instance answerNo inbound ICMP Echo Request ruleFix - 2
ping to the IPv4 address works, ping6 to the IPv6 address times outYou are using ping6 but only an IPv4 ICMP rule existsFix - 3
Pinging from the instance to another host fails, while pinging into the instance worksThe instance cannot send ping out: outbound rule missingFix - 4
The rule is there and still no reply, or replies are lost along the pathA firewall, or network latency, between you and the instanceFix
- 1
What does the error look like?
Request timed out.100% packet loss
Cause 1 of 4
No inbound ICMP Echo Request rule
1Check
The ping command is ICMP. AWS says inbound rules must allow the ICMP Echo Request message from all sources, or from the computer you ping from. A TCP rule for port 22 or 80 does not cover it.
aws ec2 describe-security-groups --group-ids sg-1234567890abcdef02Fix
Add an inbound ICMP rule. In the console choose Custom ICMP - IPv4 with Echo request, and set the source to your own public IPv4 address rather than anywhere. With the CLI, ICMP type -1 and code -1 means all ICMP types and codes.
aws ec2 authorize-security-group-ingress \
--group-id sg-1234567890abcdef0 \
--ip-permissions 'IpProtocol=icmp,FromPort=-1,ToPort=-1,IpRanges=[{CidrIp=203.0.113.25/32}]'3Verify
ping the instance's public IPv4 address or DNS name.
ping -c 4 ec2-203-0-113-25.compute-1.amazonaws.comConfirmed by docs.aws.amazon.com
Cause 2 of 4
You are using ping6 but only an IPv4 ICMP rule exists
1Check
IPv6 ping needs its own rule. The EC2 docs list an inbound All ICMP - IPv6 rule (protocol IPv6 ICMP, number 58) for ping6.
aws ec2 describe-security-groups --group-ids sg-1234567890abcdef02Fix
Add the ICMPv6 inbound rule for your IPv6 address or range.
aws ec2 authorize-security-group-ingress \
--group-id sg-1234567890abcdef0 \
--ip-permissions 'IpProtocol=icmpv6,Ipv6Ranges=[{CidrIpv6=2001:db8:1234:1a00::/64}]'3Verify
ping6 the instance's IPv6 address.
ping6 -c 4 2001:db8:1234:1a00::25Confirmed by docs.aws.amazon.com
Cause 3 of 4
The instance cannot send ping out: outbound rule missing
1Check
If the instance is the one issuing ping, the outbound rules must allow ICMP Echo Request to all destinations or to the host you target. This matters when someone removed the default allow-all outbound rule.
aws ec2 describe-security-groups --group-ids sg-1234567890abcdef02Fix
Add an outbound ICMP Echo Request rule for the destination you want to test. In the console, open the security group, choose Edit outbound rules, and add Custom ICMP - IPv4 with Echo request.
# EC2 console > Security groups > your group > Outbound rules > Edit outbound rules3Verify
Run ping from the instance to that host.
ping -c 4 198.51.100.7Confirmed by docs.aws.amazon.com
Cause 4 of 4
A firewall, or network latency, between you and the instance
1Check
The AWS page says ping can also be blocked by a firewall, or time out from network latency or hardware problems. Test from a second network (for example a phone hotspot) to see whether your own network drops ICMP.
ping -c 4 ec2-203-0-113-25.compute-1.amazonaws.com2Fix
Ask the owner of the corporate or home network to allow ICMP, or test from a network that does.
# ask the network owner to allow ICMP echo, or check the firewall running on the instance3Verify
A reply arrives from the second network.
ping -c 4 ec2-203-0-113-25.compute-1.amazonaws.comConfirmed by docs.aws.amazon.com
How do I stop it coming back?
- Treat ping as optional: test a real service port (22, 80, 443) when you want to know whether the app is reachable.
- Open ICMP only to your own address range, not to 0.0.0.0/0, unless the instance has a reason to answer everyone.
- Keep the security group rules in infrastructure code so a missing ICMP rule shows in review.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- RaheebA consumer app shipped to both stores from one Flutter codebase on a .NET and Azure back end.
- Loade DriverThe driver side of a delivery platform: live jobs, routing and earnings, past 5K Google Play downloads.
Related fixes
Servers
ssh to an EC2 instance hangs and ends in Connection timed out
Network error: Connection timed out
A timeout means your packets never got an answer, so this is a network path problem, not a key problem.
4 causes, each with a fixServers
Status code 460 on an AWS Application Load Balancer
elb_status_code 460 in ALB access logs
A 460 is generated by the load balancer, not by your app.
3 causes, each with a fixServers
Application Load Balancer returns 504 for requests to EC2 instances
HTTPCode_ELB_504_Count
A 504 from an Application Load Balancer means it could not get an answer from a target in time.
4 causes, each with a fixServers
Apache has a certificate, but https:// does not open
No line with :443 in the output of ss -ltnp
HTTPS needs four things at once: mod_ssl loaded, Apache listening on 443, a virtual host on 443 with SSLEngine on, and a firewall that lets 443 in.
4 causes, each with a fixServers
aws emr --steps fails: Error parsing parameter, Expected '=', received 'EOF'
Error parsing parameter '--steps': Expected: '=', received: 'EOF' for input:
The AWS CLI tried to read your option as shorthand key=value pairs and ran out of text where it expected an equals sign.
3 causes, each with a fixServers
AWS CLI says you must specify a region
You must specify a region. You can also configure your region by running "aws configure".
The AWS CLI sends every request to one region and has none to use.
4 causes, each with a fix