Cannot Ping Public IP but Can Ping Public DNS of a Public EC2 Instance - Troubleshooting Guide

Abstract: Resolve inability to ping EC2 public IP by allowing inbound ICMP Echo Request traffic in security groups and network ACLs.

Created: 2026-10-11 by

Being unable to ping the public IP of an Amazon EC2 instance while successfully pinging its public DNS name usually indicates that ICMP Echo Requests are being blocked by a security group or network ACL, rather than a DNS resolution failure. Since the DNS resolves correctly, the underlying network path exists, but AWS default configurations often drop outbound ICMP traffic from instances for security reasons. This guide details how to verify and adjust these network controls to restore connectivity.

Understanding the Root Cause

The discrepancy between failing to ping an IP address and succeeding with a DNS name is a common point of confusion for new AWS users. It is critical to understand that Domain Name System (DNS) resolution and Internet Control Message Protocol (ICMP) traffic are two separate layers of the networking stack. When you ping a domain name, your local machine first queries a DNS server to translate that name into an IP address. If this step succeeds, it confirms that your local network has valid DNS settings and can reach external servers. However, once the IP address is resolved, your machine attempts to send an ICMP Echo Request packet to that specific IP. In the context of Amazon EC2, the most frequent reason for this second step failing is not a routing issue, but a firewall rule within the AWS infrastructure itself. By default, security groups associated with EC2 instances do not allow inbound ICMP traffic. This means that even though the instance is publicly accessible via SSH (port 22) or HTTP/HTTPS (ports 80 and 443), it will silently drop any ping attempts directed at its public IP address. Therefore, the ability to ping the DNS name only proves that name resolution works; it does not guarantee that the instance accepts ICMP packets. To resolve this, you must inspect the network security rules governing the instance. The troubleshooting process involves checking both the Security Group attached to the instance and any Network Access Control Lists (NACLs) applied to the subnet. These components act as virtual firewalls, and misconfigurations in either can block diagnostic tools like ping.

Configuring Security Groups for ICMP

Security groups are stateful packet firewalls that control inbound and outbound traffic at the instance level. To allow ping requests, you need to modify the inbound rules of the security group associated with your EC2 instance. Log in to the AWS Management Console and navigate to the EC2 dashboard. Locate your instance in the list of running instances and click on the ID to view its details. In the lower pane of the instance details window, find the section labeled "Security groups." Click on the security group ID link to open its configuration page. Select the "Inbound rules" tab. Here, you will see a list of rules currently allowing traffic. Look for a rule that allows ICMP traffic. If no such rule exists, or if the rule restricts ICMP to a specific source CIDR that does not include your current IP address, you must add a new rule. Click "Edit inbound rules" and then "Add rule." In the rule type dropdown, select "All ICMP - IPv4" or specifically "Echo Request" if you want to be more granular. For the Source field, enter 0.0.0.0/0 to allow ping requests from any IP address, or specify your own IP address in CIDR notation for enhanced security. Save the changes. After applying this rule, wait a few moments for the configuration to propagate, and then attempt to ping the public IP address again. If you are using the AWS CLI, you can achieve the same result by modifying the security group with the following command structure:
aws ec2 authorize-security-group-ingress \
    --group-id sg-xxxxxxxxxxxx \
    --protocol icmp \
    --type echo-request \
    --cidr 0.0.0.0/0

Checking Network ACLs

While security groups are the most common culprit, Network ACLs (NACLs) provide an additional layer of security at the subnet level. Unlike security groups, NACLs are stateless, meaning they evaluate traffic separately for inbound and outbound directions. If a security group allows ICMP but the subnet's NACL blocks it, the ping will still fail. Navigate to the VPC dashboard in the AWS Management Console and select "Network ACLs" from the left-hand menu. Identify the NACL associated with the subnet where your EC2 instance resides. Check the "Inbound rules" table. Ensure there is a rule with a low rule number (e.g., 100) that allows TCP, UDP, and ICMP traffic from 0.0.0.0/0. The action should be set to "Allow." If the only rule is a default deny-all rule at the highest number, and no explicit allow rule exists for ICMP, you must add one. Similarly, check the "Outbound rules" to ensure that return traffic is permitted. Although NACLs are stateless, standard configurations usually allow all outbound traffic by default. If you have customized these rules, ensure that ICMP Echo Replies are allowed back to your source IP.

Verifying Instance-Level Firewall Settings

Sometimes, the issue lies not within AWS infrastructure but inside the operating system of the EC2 instance itself. Even if AWS allows the traffic through, the guest OS may have its own firewall configured to drop ICMP packets. For Linux instances, check the status of iptables or nftables. You can test this by temporarily disabling the firewall using sudo systemctl stop firewalld or sudo ufw disable. If ping starts working after this change, you need to configure your internal firewall to explicitly allow ICMP traffic before re-enabling it. For Windows instances, open the Windows Defender Firewall with Advanced Security. Check the inbound rules for "File and Printer Sharing (Echo Request - ICMPv4-In)." Ensure this rule is enabled for the appropriate network profile (Domain, Private, or Public). If it is disabled, right-click and select "Enable Rule."

Testing Connectivity

After adjusting security groups, NACLs, and instance firewalls, test the connection from your local machine. Use the ping command followed by the public IP address of the instance. If the ping is successful, you will see replies indicating round-trip times. If it continues to fail, verify that the instance is actually running and that its public IP has not changed due to a stop/start cycle. Remember that Elastic IPs remain static, whereas standard public IPs can change upon reboot unless an EIP is associated. For deeper diagnostics, use traceroute (or tracert on Windows) to see where packets are dropping. If the trace stops before reaching the instance, the issue may be upstream. If it reaches the instance but shows no replies, the drop is likely at the instance-level firewall or security group.

Frequently Asked Questions

Why can I SSH into my instance but not ping it?

This is normal behavior because SSH uses TCP port 22, which is typically allowed by default security groups, while ping uses ICMP, which is often blocked by default. Allowing ICMP in the security group enables ping without affecting SSH connectivity.

Does changing the DNS settings on my router affect EC2 ping?

No, router DNS settings only affect name resolution. As seen in related guides on slow networks, DNS issues cause timeouts during name lookup, not packet drops after resolution. See Having Trouble with a Slow Network? Check Your Device's DNS on Your Network Router for more on DNS resolution limits.

What is the difference between Security Groups and NACLs?

Security groups are stateful and operate at the instance level, meaning return traffic is automatically allowed. NACLs are stateless and operate at the subnet level, requiring explicit rules for both inbound and outbound traffic. Misconfigured NACLs can block traffic even if security groups permit it.

Can I use an Elastic IP to solve ping issues?

An Elastic IP provides a static public address but does not inherently fix ping issues. If ICMP is blocked by security groups, changing the IP address will not change the firewall rules. You must still modify the security group regardless of whether you use a standard or Elastic IP.

How do I troubleshoot if ping works locally but not from other machines?

If ping works from your local machine but fails from others, your security group source rule might be restricted to your specific IP CIDR. Change the source to 0.0.0.0/0 to allow global access, or add specific CIDRs for other trusted networks.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More