In-depth guide: Ping command

Ping is the simplest way to answer a fundamental question: can my device reach another device on the network?

It may seem like a basic tool, but it becomes incredibly useful once you understand when and how to use it. Whether you're troubleshooting why a website won't load, checking your connection quality, or measuring latency to a remote server, ping is usually where you start.

This guide covers everything you need to know about ping: how it works, how to use it effectively, and how to interpret what it's telling you. We'll also show you how Globalping takes ping further by letting you run tests from anywhere in the world, not just from your local machine.

Let's dive in!

Getting started with ping

Let's start with the basics first. In this section, you'll learn what the ping command is, how it works, and how to run it on your own machine. We'll walk through some examples and see how to tell when a ping is successful and when it's not.

What is ping, and how does it work?

Ping is a command-line tool that tests whether your device can reach another device or server on a network. It's essentially sending a "Hey, are you there?" message and waiting for a response.

The name "ping" actually comes from sonar technology, where submarines, for example, send out sound waves to detect objects underwater. Ping works similarly: your device sends a small packet of data, called an ICMP Echo Request, to a target. If the target is reachable, it sends back an ICMP Echo Reply.

A device (host) sends and ICMP echo request to another device (target), which sends back an ICMP echo reply.

In addition to confirming that a target is reachable, ping also provides other valuable information:

  • Packet loss: The percentage of packets that never made it to their destination. Packet loss usually means network congestion or an unstable connection.
  • Round-Trip Time (RTT): How long it takes for a packet to reach the target and come back. Lower is better, though some variation is normal.

How to run ping

Running ping is straightforward and works almost identically on Linux, macOS, and Windows.

Basic ping syntax

The basic syntax for running a ping command is:

ping [options] target

  • target: The hostname or IP address you want to ping, like a website, server, or device on your local network.
  • options: Optional parameters to customize the command (number of packets, packet size, timeout, etc.).

Example: Pinging a website

Let's test connectivity to the Globalping website by running the following command in your terminal:

ping globalping.io

Hit Enter, and you'll start to see the ping results: a line for each response and a short summary at the end. A successful response means the connection works. Messages like "Request timed out" mean there's a problem. We'll look into how to read these results later in the guide.

💡
Note: On Linux and macOS, ping runs until you stop it manually with CTRL + C.

A successful ping on Windows can look like this:

An example showing the result of running ping on Windows.

On Linux or macOS:

An example showing the result of running ping on Linux or macOS.

Useful flags

Ping includes several flags that let you customize how it runs. Here are the most practical ones.

Note: Flags differ between Windows and Linux/macOS, so we've split them up.

Windows

  • -t - Ping continuously until you stop it with Ctrl+C
  • -n count - Send a specific number of packets (e.g., -n 10 sends 10 packets)
  • -l size - Set the packet size in bytes (e.g., -l 1000 uses 1000-byte packets)
  • -w timeout - Set the maximum time in milliseconds to wait for each reply before considering it a failure (e.g., -w 5000 waits 5 seconds for a reply)

Example: ping -t -n 100 globalping.io

Linux

  • -c count - Send a specific number of packets (e.g., -c 4 sends 4 packets and stops)
  • -i interval - Set the time between packets in seconds (e.g., -i 2 waits 2 seconds between each)
  • -s packetsize - Set the packet size in bytes (e.g., -s 1000 uses 1000-byte packets)
  • -W timeout - Set the maximum time in seconds to wait for each reply before considering it a failure (e.g., -W 5 waits 5 seconds for a reply)
  • -q - Quiet output; only show a summary at the end

Example: ping -c 10 globalping.io

Remember that by default, Windows sends four packets and then stops automatically. Linux and macOS keep pinging until you stop them manually with CTRL+C.

When do you use ping?

Now that you know how to use ping, let's look at when it can help you.

In general, ping helps you check reachability, latency, and overall network health. It's usually the first tool you go for when something isn't working, such as a slow website or an unreachable device. By looking at ping results, you can narrow down where the problem is: your device, your network, or the remote server.

Here are some common use cases for ping:

Checking network connectivity

When you're having network issues, start by pinging your default gateway (your router). If you get a reply, your device can communicate with the router, meaning your local connection is fine. If not, there's likely a local network problem, such as a bad cable or Wi-Fi issue.

Testing website reachability

If a website doesn't load, ping its domain name. A successful reply means that your device can reach it. But if you see messages like Request timed out, the host may be down, unreachable, or blocked by a firewall.

An example ping result of an unreachable host.

In this example, every ping request times out. This usually happens when there's a network outage, a firewall blocking the request, or the server is down.

Detecting packet loss

Packet loss means some of your data never reaches its destination. In ping results, repeated timeouts or Request Timed Out messages indicate that some packets are getting lost along the way.

An example ping result with 16.67% packet loss.

Here, ping sent 6 packets but only received 5, which is 16.67% packet loss. This could mean network congestion or a faulty connection along the path.

Measuring latency

Ping also measures latency, which is the time it takes for a packet to travel to the destination and back (round-trip time, RTT). Unusually high RTTs can indicate network congestion, long physical distances, or routing problems.

An example ping result sowing unusually high latency.

In this example, each ping shows high RTT (around 98–109 ms). The average in the summary confirms the connection is slower than normal. This is what causes laggy video calls, buffering, and delayed app responses.

Ping is a quick way to confirm whether something is reachable and how efficiently data moves through the network. Once you've identified an issue, you can further investigate using tools such as traceroute, mtr, or curl.

How to read ping results

When you run ping, you'll see one line for each response, followed by a summary at the end. Even without knowing every detail, you can quickly tell whether a website or device is reachable and how stable the connection is.

Still, understanding the full output is helpful when troubleshooting. So, let's break down what you're looking at.

Let's look at a ping result from a Linux terminal from earlier in the guide again:

Example ping result to globalping.io, which we'll use to explain how to read ping results.

What the output means:

  1. Destination IP address or hostname: The first line shows the target you're pinging.
  2. Packet size: The size of each ICMP packet, like 56 data bytes.
  3. Ping responses: Each line is one reply:
    1. 64 bytes from IP_ADDRESS: Successful reply from the target
    2. icmp_seq: Packet sequence number (starts at 1)
    3. ttl: Time-to-Live; how many router hops the packet can cross before giving up. Lower values mean the packet traveled through more routers.
    4. time: Round-trip time (RTT) in milliseconds; it tells you how long it took for the packet to reach the target and come back.
  4. Summary: Statistics at the end:
    1. Packet loss: The percentage of packets that didn’t return.
    2. Round-Trip Time (RTT): Four values showing your connection speed:
      1. Minimum: fastest response
      2. Average: average response time
      3. Maximum: slowest response
      4. Mean Deviation: How much response times varied (lower means more stable)

What's "good" or "bad" latency?

RTT (time in milliseconds) indicates how fast your connection is. Here are general benchmarks:

  • Excellent (1-20ms): Local network or nearby servers. Perfect for gaming and video calls.
  • Good (20-50ms): Typical for nearby locations. Feels instant for most use cases.
  • Okay (50-100ms): Fine for browsing and streaming, but can cause slight lag in some online games.
  • Poor (100-200ms): Noticeable delays in calls or games, slower webpage loads.
  • Bad (200ms+): Significant lag across the board.
💡
Tip: Consistent 60ms latency is better than bouncing between 20ms and 200ms. Stability is more important than occasional spikes.

Common error messages

Ping errors help you diagnose where problems are happening. Here are the most common ones:

Request timed out / no answer yet

  • What it means: Your ping was sent, but nothing came back in time.
  • Possible causes: Destination is offline, blocking ICMP requests, or there's packet loss.

Destination host unreachable

  • What it means: Your computer or router can't find a path to the target.
  • Possible causes: Network disconnected, wrong IP address, or misconfigured router.

Unknown host / ping: cannot resolve hostname

  • What it means: Your computer can't convert the domain name into an IP address (DNS lookup failed).
  • Possible causes: Typo in the domain name, DNS issues, or no internet.

General failure

  • What it means: Something's wrong with your network setup.
  • Possible causes: Disabled or misconfigured network adapter, no IP assigned, or driver issues.

TTL expired in transit

  • What it means: The packet went through too many routers and was dropped.
  • Possible causes: Routing loop or very long distance.

How to ping from anywhere

Sometimes you need to test connectivity from somewhere other than your own machine. Maybe you want to see if users in Asia can reach your website, or how your CDN performs across different regions.

You could use a VPN or SSH into a remote server, but those methods are limited and often unavailable. And what if you want to run pings from multiple locations at once?

That's where Globalping comes in. Globalping is a community-powered network testing platform that lets you run networking commands such as ping, traceroute, dig, curl, and mtr, from anywhere in the world for free.

Globalping works through a network of thousands of probes hosted by community members in their homes, offices, and servers. When you send a measurement request, Globalping's API selects fitting probes in your desired locations, runs your command, collects the results, and sends them back to you.

Why use Globalping for running ping?

Test from multiple perspectives

Running ping from your own device only shows how your network performs. With Globalping, you can test from locations around the world to see how users in different regions experience your service. This gives you a much more complete picture of reachability and latency.

Troubleshoot faster

Globalping lets you run pings from multiple locations simultaneously, saving time when troubleshooting network issues. Instead of testing one location at a time through VPNs or remote servers, you can identify problems quickly, even if they're thousands of kilometers away.

Get global network insights

Modern apps and websites serve users everywhere. Globalping lets you see your network from that same global perspective. You can quickly spot regional latency issues, routing problems, or outages, then use those insights to improve your infrastructure and user experience.

How to ping with Globalping

Globalping is designed for users of all skill levels. We offer multiple integrations to make network testing flexible and straightforward, including a web tool, a command-line tool, a Slack app, an MCP server, and a public API. You can explore all integrations here.

In this section, we'll show you how to ping using the Globalping web tool, CLI, and API. We recommend you start with the web tool if you're new to Globalping.

Use the web tool for quick results

The web tool is perfect if you prefer a visual interface or want to run tests from any device with a browser.

Visit the Globalping website and you'll see a form and a map at the top of the page.

When you visit our website, you can find our web tool at the very top of the page.

Available form fields:

  • Test type: Select the network command you want to run
  • Target: Enter the target's hostname or IP address
  • Location: Specify where you want to run the test from
  • Limit: Number of probes to use
  • Settings: Command-specific options. For ping, you can set the number of packets to send
  • Map: Toggle to display results on the map below

Example: Ping globalping.io from 10 random locations in Europe.

Fill in the form:

  • Test type: ping
  • Target: globalping.io
  • Location: Europe
  • Limit: 10
  • Click "Run test"

After a moment, the results will appear on the map. Each marker represents a probe location, and its color reflects the average RTT. Click on a marker to see more details.

You can see all probes used for your measurement on a map.

Below the map, you'll see individual ping results. Each entry shows the probe's location, Autonomous System Number (ASN), average RTT, and packet loss percentage. At the bottom, there's also a button to copy a shareable link to your results.

Below the map, you can find each probe's test result.

Ping from anywhere using the CLI

Once you've successfully installed the CLI tool, you can run all Globalping commands directly from your terminal.

To see available options and examples, run:

$ globalping ping --help

Basic command structure:

$ globalping [command type] [target] from [location] [flags]

Example: Ping the Globalping website from Vienna and Berlin

$ globalping ping jsdelivr.com --from Vienna,Berlin

An example response showing a successful ping with Globalping.

If you don't specify a limit (number of probes), Globalping defaults to one probe. In this example, it randomly selects one probe from either Vienna or Berlin. If you set the limit to 2, it picks one probe from each city:

$ globalping ping jsdelivr.com --from Vienna,Berlin --limit 2

You can also run ping from multiple probes at once.

Use the API

You can also run ping measurements programmatically using the Globalping API. This is useful for building custom tools, automating tests, or running measurements from environments where traditional ping isn't available (for example, from client-side JavaScript).

Try the API directly in our API reference using the built-in testing functionality. For a detailed walkthrough, check out our blog post on using the API.

Example: Ping the Globalping website from the US and Germany

Step 1: Create the measurement

Send a POST request to the /measurements endpoint with your test parameters:

Use the "Try" functionality in our API reference to create test measurements.

A successful request returns a measurement ID, which you'll use to fetch the ping results.

Step 2: Retrieve the results

Provide the measurement ID to the /measurements/{id} endpoint:

Provide the measurement ID to retrieve your measurement results.

The response includes detailed information for each probe used in the test, and, of course, the ping results.

Measurement results come back as JSON, containing info about used probes and their ping results.
  • results.probe: Contains details about the probe’s location, network, and tags.
  • results.result: Contains the raw ping output along with timing and packet loss statistics.

Customize your ping requests

Globalping provides several ways to fine-tune your tests, including "magic" location selection and optional flags.

Use the "magic" location field

You can specify locations in many ways:

  • Country names (e.g., Greece)
  • Continents (e.g., Asia)
  • Cities (e.g., Warsaw)
  • US states (e.g., Idaho)
  • Regions (e.g., South America)
  • ASNs (e.g., 3209 for Vodafone Germany)
  • Cloud regions (e.g., us-east-2)

You can also target previously used probes or probes with specific tags. What's more, you can combine locations to narrow down the selection, like US+AWS to select a probe in the AWS network in the US.

Check our GitHub README to see all options and best practices.

Use available flags

Most integrations support additional flags that influence how the command runs.

  • In the web app, these appear as form options
  • For the API, you can find them documented in our API reference.
  • For the CLI (and similar integrations), run globalping ping --help

Here are some handy ping CLI flags:

  • --infinite: continuously ping the target until manually stopped
  • --packets: number of echo request packets to send
  • --json: return the response in JSON format
  • --latency: output only latency statistics
  • --ci: disable colors and real-time updates (for CI environments)

And that covers the basics of using Globalping. Next, just pick whichever tool fits your workflow and start running tests from around the world.

Conclusion

Ping is often the first command you run when diagnosing network issues because it quickly tells you whether a host is reachable, how fast the connection is, and whether packets are being lost along the way.

We hope you now know how ping works, how to run it on your own machine, how to interpret the results, and when to use it.

We've also explored how you can test from multiple locations around the globe with Globalping. As a result, you are now able to see how your service performs across different countries, ISPs, and network types, giving you the complete picture rather than just your local perspective.

Try pinging with the Globalping web tool – it's free to use.