The ping command checks whether another device answers over the network and how long the round trip takes: run ping example.com on Windows, or ping -c 4 example.com on Linux. Replies with a time value mean the host is reachable; Request timed out or 100% loss means the packets or the replies are being lost or blocked somewhere on the way.
How ping works
Ping sends ICMP Echo Request messages (ICMP type 8) and waits for Echo Reply messages (type 0) back, as defined in RFC 792. The target must return the same data it received, which is how ping matches each reply to its request and times the round trip. Because it uses ICMP rather than TCP or UDP, ping has no port number: it tests whether the machine is reachable at the IP level, not whether a particular service such as a web server is running.
How to use ping on Windows
ping example.com
Windows sends 4 requests by default, each with 32 bytes of data, and waits up to 4,000 ms (4 seconds) for each reply. Example output:
Pinging example.com [203.0.113.10] with 32 bytes of data:
Reply from 203.0.113.10: bytes=32 time=43ms TTL=55
Reply from 203.0.113.10: bytes=32 time=47ms TTL=55
Ping statistics for 203.0.113.10:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 43ms, Maximum = 47ms, Average = 45ms
(That run used -n 2 to send two requests; addresses in all examples here are replaced with documentation addresses.) Windows accepts both -n and /n style options.
How to use ping on Linux
ping -c 4 example.com
On Linux, ping keeps going until you press Ctrl+C, so -c sets a count. It sends 56 data bytes, which becomes 64 bytes with the 8-byte ICMP header, one packet per second. Example output against the local machine:
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.017 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.022 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.025 ms
--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2100ms
rtt min/avg/max/mdev = 0.017/0.021/0.025/0.003 ms
84 in the first line adds the 20-byte IPv4 header. icmp_seq numbers each request, so a gap in the sequence shows exactly which packets were lost. mdev is the spread of the times: a large value relative to the average means jittery latency.
How to read the results
| Field | What it tells you |
|---|---|
time | Round-trip time in milliseconds: request out, reply back. time<1ms on Windows means under one millisecond. |
TTL / ttl | The Time To Live left in the reply when it arrived. Each router on the way subtracts 1. |
| Lost / packet loss | Requests that got no reply within the timeout. Any loss to your own router points at your local network or Wi-Fi. |
| Minimum / Maximum / Average | A big gap between minimum and maximum means unstable latency (often Wi-Fi interference or a congested link). |
The TTL lets you estimate how far away a host is. Senders start from a fixed value: in the outputs above, Windows replies started at 128 and Linux at 64. The reply from example.com arrived with TTL=55. If it started at 64, it passed through 64 − 55 = 9 routers, and a tracert to the same host on the same connection showed 9 hops. The starting value is a guess, so treat this as an estimate. To see each hop, use tracert or traceroute.
What ping errors mean
| Message | Meaning |
|---|---|
Request timed out. | No reply within the timeout (4 seconds by default on Windows). The host may be down, a firewall may drop ICMP, or the reply may be lost on the way back. |
Reply from 192.168.1.20: Destination host unreachable. | A device (often your own PC, or a router) could not deliver the packet. When the "Reply from" address is your own, the target on your local network didn't answer at all. |
Ping request could not find host nosuch.invalid. Please check the name and try again. | DNS lookup failed: the name doesn't exist or your DNS isn't working. On Linux: ping: nosuch.invalid: Name or service not known. |
Reply from 203.0.113.1: TTL expired in transit. | The packet ran out of TTL at that router before reaching the target, usually a routing loop, or a TTL you set too low with -i. |
Packet needs to be fragmented but DF set. | You sent a packet larger than the path allows with the Don't Fragment flag (-f). See the MTU section below. |
One trap: Windows counts "Destination host unreachable" replies as received. A test against an unused local address printed Sent = 2, Received = 2, Lost = 0 (0% loss) even though the target never answered. Read the reply lines, not just the summary.
Useful ping options
| Task | Windows | Linux |
|---|---|---|
| Send N requests | -n 10 | -c 10 |
| Run until stopped | -t | (default) |
| Packet data size | -l 1000 (default 32, max 65,500) | -s 1000 (default 56) |
| Reply timeout | -w 1000 (milliseconds) | -W 1 (seconds) |
| Force IPv4 / IPv6 | -4 / -6 | -4 / -6 |
| Set TTL | -i 5 | -t 5 |
| Don't fragment | -f | -M do |
| Show only the summary | (none) | -q |
On Linux, ping's exit code is 0 when replies came back, 1 when none did, and 2 for other errors, so ping -c 1 -W 1 host >/dev/null && echo up works in scripts.
Using ping to find where a connection breaks
Work outwards and stop at the first step that fails:
ping 127.0.0.1: tests your own network stack. If this fails, the problem is on the PC itself.ping 192.168.1.1(your router's address, shown as "Default Gateway" inipconfigor byip routeon Linux): tests your local link, cable or Wi-Fi.ping 1.1.1.1: a public IP address. If this works but the next step fails, the internet connection is fine and DNS is the problem.ping example.com: tests name resolution as well. Microsoft's ping documentation makes the same point: if pinging the IP address works and pinging the name doesn't, you have a name resolution problem. The DNS explainer and flushing your DNS cache are the next stops.
How to find your MTU with ping
Send packets with Don't Fragment set and increase the size until they stop fitting:
ping -n 1 -f -l 1464 example.com
ping -n 1 -f -l 1465 example.com
On the test connection, 1,464 bytes got a normal reply and 1,465 returned Packet needs to be fragmented but DF set. Add the 8-byte ICMP header and 20-byte IPv4 header: 1,464 + 28 = 1,492 bytes, which is that path's MTU. On a standard 1,500-byte Ethernet path the largest working value is 1,472. The Linux equivalent is ping -c 1 -M do -s 1464 example.com.
If ping times out but everything else works
That usually means ICMP is filtered, not that the host is down. Test the actual service instead: Test-NetConnection example.com -Port 443 in PowerShell, or curl -I https://example.com on any system. If that connects, the host is up and only ping is being filtered. If both fail, run a tracert to see how far the packets get before they disappear.
Frequently asked questions
- What is a good ping time?
- It depends mostly on distance, so compare like with like. On the connection used for this article, the local machine answered in under 1 ms, the home router in about 1 ms, and a large website's server in 43 to 47 ms. Consistency matters as much as the number: if repeated pings to the same host swing widely, look for congestion or a weak Wi-Fi signal.
- Why does ping fail when the website still loads?
- Ping uses ICMP echo messages, while websites use TCP on ports 80 and 443. Servers and firewalls can be configured to drop ICMP echo requests, so a host can serve web pages perfectly and still time out on ping. A failed ping only proves something when the same host normally answers it.
- How do I ping continuously on Windows?
- Use ping -t host. It keeps sending until you stop it. Press Ctrl+Break to print statistics and keep going, or Ctrl+C to stop and print the summary. On Linux, ping already runs continuously by default; use -c 4 to send a fixed number.
- Does ping test my internet speed?
- No. Ping measures round-trip latency and packet loss with tiny packets (32 bytes of data on Windows, 56 on Linux). Bandwidth, how many megabits per second you can transfer, needs a throughput test that moves real amounts of data.