Ping an EC2 instance from your Local Machine

avatar
Borislav Hadzhiev

Last updated: Feb 26, 2024
2 min

banner

# How to Ping an EC2 instance from your Local Machine

To ping an AWS EC2 instance from your local machine:

  1. Open the AWS EC2 console and click on the checkbox next to your EC2 instance.
  2. Click on Security and open the security group in a new browser tab.

open security group

  1. In the "Inbound rules" tab of your security group, click on "Edit inbound rules".

edit inbound rules

  1. Click on the "Add rule" button and add the following inbound rule:
  • Type: Custom ICMP - IPv4
  • Protocol: Echo Request
  • Port: N/A
  • Source: Anywhere-IPV4

allow ping inbound rule

The security group rule allows Ping requests to the EC2 instance from any IP address in the world.

  1. Click "Save rules".
If you want to scope down the IP addresses that are allowed to ping your EC2 instance, for Source select My IP. This will only enable you to ping the instance from your current IP address.
  1. Back in the EC2 console, verify the checkbox next to your EC2 instance is checked.
  2. In the Details tab, copy the Public IPv4 DNS address of your instance.

copy EC2 public DNS

  1. Use the ping command to ping your EC2 instance from your local machine.
shell
ping YOUR_EC2_PUBLIC_DNS

ping request

By default, a security group denies all inbound access, so anytime you want to enable access to your EC2 instance, you have to edit its security group.

In our case, to allow inbound ping requests to the instance, we had to add a new inbound security group to allow ICMP traffic.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.