Applies to: the ping command on Windows 10, 11 and Windows Server (options from Microsoft’s command reference); Test-Connection tested in PowerShell 7.6.6
To ping on Windows, open Command Prompt or PowerShell (press Start, type cmd and press Enter) and type ping followed by a name or IP address, for example ping example.com. According to Microsoft, Windows then sends 4 echo requests with 32 bytes of data and shows each reply with its round-trip time. Use ping /t to keep pinging until you stop it.
Reading the result
Microsoft’s reference shows a successful ping like this:
C:\>ping example.microsoft.com
pinging example.microsoft.com [192.168.239.132] with 32 bytes of data:
Reply from 192.168.239.132: bytes=32 time=101ms TTL=124
Reply from 192.168.239.132: bytes=32 time=100ms TTL=124
Reply from 192.168.239.132: bytes=32 time=120ms TTL=124
Reply from 192.168.239.132: bytes=32 time=120ms TTL=124
- [192.168.239.132]: the IP address the name resolved to. Useful to check that DNS points where you expect.
- time=101ms: round-trip time, the delay to the server and back. Lower is better.
- TTL: the time-to-live left in the reply packet.
- Request timed out: no reply arrived within the time-out (4 seconds by default).
Useful options
ping /t 203.0.113.10 # until Ctrl+C (Ctrl+Break shows statistics) ping /n 10 203.0.113.10 # 10 requests instead of 4 ping /l 1000 203.0.113.10 # 1,000 bytes of data instead of 32 (max 65,500) ping /f /l 1472 203.0.113.10 # IPv4 with Don't Fragment set, to find MTU problems ping /w 1000 203.0.113.10 # wait 1,000 ms for each reply (default 4,000) ping /a 203.0.113.10 # also look up the host name of the IP ping /4 example.com # force IPv4 (or /6 for IPv6) ping /i 10 203.0.113.10 # set the TTL of the requests
All options come from Microsoft’s ping reference; we couldn’t run Windows in our Docker test lab.
What a failed ping means
- Ping by IP works, by name doesn’t: a name resolution problem, as Microsoft’s reference points out. Check the DNS records, flush the DNS cache or change your DNS servers.
- Request timed out for every request: the host is down, a route is broken, or a firewall drops ping (ICMP). Some servers block ping on purpose, so also test the service port (below) before you decide a server is down.
- Some replies time out: packet loss on the way. Run
ping /n 100and compare the loss at different times; traceroute shows where it happens.
Test a port instead of ping
Ping only shows that the machine answers ICMP. To check that a website or Remote Desktop answers, test the TCP port. In PowerShell 7 this worked in our test:
PS> Test-Connection -TargetName 1.1.1.1 -TcpPort 443 True
In Windows PowerShell 5.1, Microsoft’s cmdlet is Test-NetConnection -ComputerName server.example.com -Port 3389; look for TcpTestSucceeded : True.
Test-Connection also replaces ping itself. Output from PowerShell 7.6.6:
PS> Test-Connection -TargetName 1.1.1.1 -Count 2
Destination: 1.1.1.1
Ping Source Address Latency BufferSize Status
(ms) (B)
---- ------ ------- ------- ---------- ------
1 c6a25a1b19a1 1.1.1.1 14 32 Success
2 c6a25a1b19a1 1.1.1.1 15 32 Success
An address that doesn’t answer shows TimedOut in the Status column.
Let your Windows server answer ping
If your own Windows server doesn’t reply, check the Windows Firewall rule File and Printer Sharing (Echo Request - ICMPv4-In), which Microsoft names as the rule that allows ping. From an administrator Command Prompt:
netsh advfirewall firewall set rule name="File and Printer Sharing (Echo Request - ICMPv4-In)" new enable=yes
More: open ports on Windows Server, ping on Linux and turn ping replies off on a Linux server.
Official documentation: ping and Test-NetConnection.