{"id":25451,"date":"2026-12-03T21:47:47","date_gmt":"2026-12-03T13:47:47","guid":{"rendered":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html"},"modified":"2026-12-03T21:47:47","modified_gmt":"2026-12-03T13:47:47","slug":"how-to-ping-a-tcp-port","status":"publish","type":"post","link":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html","title":{"rendered":"How to Ping a TCP Port"},"content":{"rendered":"<p>When a web server, database, or remote desktop session fails to respond, running a standard <code>ping<\/code> only tells you whether the remote machine is online\u2014not whether the specific service port is open and accepting connections. Checking a specific port requires &#8220;pinging&#8221; over TCP to verify that packets can traverse intermediate firewalls and complete a handshake with the target application. Below, you will learn why traditional ping cannot target ports, how to run TCP port checks natively on Windows, Linux, and macOS, how to interpret timeouts versus refusals, and how to monitor port latency or batch-test firewall rules at scale.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_17 counter-hierarchy counter-decimal ez-toc-light-blue\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Why_the_Standard_Ping_Command_Cannot_Specify_a_TCP_Port\" title=\"Why the Standard Ping Command Cannot Specify a TCP Port\">Why the Standard Ping Command Cannot Specify a TCP Port<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Can_you_pass_a_port_number_to_the_standard_ping_command\" title=\"Can you pass a port number to the standard ping command?\">Can you pass a port number to the standard ping command?<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#What_is_the_difference_between_an_ICMP_ping_and_a_TCP_port_ping\" title=\"What is the difference between an ICMP ping and a TCP port ping?\">What is the difference between an ICMP ping and a TCP port ping?<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#How_does_TCP_handshake_probing_work_compared_to_standard_ping\" title=\"How does TCP handshake probing work compared to standard ping?\">How does TCP handshake probing work compared to standard ping?<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#How_to_Ping_a_TCP_Port_on_Windows_PowerShell_and_CMD\" title=\"How to Ping a TCP Port on Windows (PowerShell and CMD)\">How to Ping a TCP Port on Windows (PowerShell and CMD)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Microsoft_PowerShell_Test-NetConnection_Reference\" title=\"Microsoft PowerShell Test-NetConnection Reference\">Microsoft PowerShell Test-NetConnection Reference<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Syntax_TCP_Port_Parameter_Sets\" title=\"Syntax (TCP Port Parameter Sets)\">Syntax (TCP Port Parameter Sets)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Parameters\" title=\"Parameters\">Parameters<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Return_Objects_and_Quiet_Mode\" title=\"Return Objects and Quiet Mode\">Return Objects and Quiet Mode<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#How_to_Ping_a_TCP_Port_on_Linux_and_macOS\" title=\"How to Ping a TCP Port on Linux and macOS\">How to Ping a TCP Port on Linux and macOS<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Troubleshooting_Failed_Tests_Connection_Timed_Out_vs_Connection_Refused\" title=\"Troubleshooting Failed Tests: Connection Timed Out vs. Connection Refused\">Troubleshooting Failed Tests: Connection Timed Out vs. Connection Refused<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#What_is_the_difference_between_Connection_timed_out_and_Connection_refused\" title=\"What is the difference between &#8220;Connection timed out&#8221; and &#8220;Connection refused&#8221;?\">What is the difference between &#8220;Connection timed out&#8221; and &#8220;Connection refused&#8221;?<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#What_do_Open_Closed_and_Filtered_port_states_mean\" title=\"What do Open, Closed, and Filtered port states mean?\">What do Open, Closed, and Filtered port states mean?<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Why_does_a_TCP_port_ping_fail_when_standard_ICMP_ping_works\" title=\"Why does a TCP port ping fail when standard ICMP ping works?\">Why does a TCP port ping fail when standard ICMP ping works?<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Best_TCP_Port_Ping_Tools_and_CLI_Utilities_Compared\" title=\"Best TCP Port Ping Tools and CLI Utilities Compared\">Best TCP Port Ping Tools and CLI Utilities Compared<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#How_to_Continuously_Ping_a_TCP_Port_to_Monitor_Latency_and_Drops\" title=\"How to Continuously Ping a TCP Port to Monitor Latency and Drops\">How to Continuously Ping a TCP Port to Monitor Latency and Drops<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Pinging_a_TCP_Port_in_Docker_Containers_and_Kubernetes_Pods_Without_Netcat\" title=\"Pinging a TCP Port in Docker Containers and Kubernetes Pods Without Netcat\">Pinging a TCP Port in Docker Containers and Kubernetes Pods Without Netcat<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Bash_devtcp_Pseudo-Device_Containers_with_binbash\" title=\"Bash \/dev\/tcp Pseudo-Device (Containers with \/bin\/bash)\">Bash \/dev\/tcp Pseudo-Device (Containers with \/bin\/bash)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Python_3_Socket_One-Liner_Supports_IPv4_IPv6_and_Cluster_DNS\" title=\"Python 3 Socket One-Liner (Supports IPv4, IPv6, and Cluster DNS)\">Python 3 Socket One-Liner (Supports IPv4, IPv6, and Cluster DNS)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Nodejs_net_One-Liner_Slim_Node_Microservice_Containers\" title=\"Node.js net One-Liner (Slim Node Microservice Containers)\">Node.js net One-Liner (Slim Node Microservice Containers)<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#PowerShell_and_Bash_Script_Templates_to_Ping_Multiple_TCP_Ports\" title=\"PowerShell and Bash Script Templates to Ping Multiple TCP Ports\">PowerShell and Bash Script Templates to Ping Multiple TCP Ports<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#PowerShell_Bulk_TCP_Port_Test_Script_Inline_or_CSV_Input\" title=\"PowerShell Bulk TCP Port Test Script (Inline or CSV Input)\">PowerShell Bulk TCP Port Test Script (Inline or CSV Input)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Bash_Bulk_TCP_Port_Test_Script_Linux_and_macOS\" title=\"Bash Bulk TCP Port Test Script (Linux and macOS)\">Bash Bulk TCP Port Test Script (Linux and macOS)<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Why_the_Standard_Ping_Command_Cannot_Specify_a_TCP_Port\"><\/span>Why the Standard Ping Command Cannot Specify a TCP Port<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Before running port connectivity commands, it helps to understand why appending a port number like <code>:443<\/code> to the built-in <code>ping<\/code> command always fails.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_you_pass_a_port_number_to_the_standard_ping_command\"><\/span>Can you pass a port number to the standard ping command?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>No. The traditional <code>ping<\/code> utility uses <strong>ICMP (Internet Control Message Protocol)<\/strong> Echo Request and Echo Reply messages, which operate at <strong>Layer 3 (Network Layer)<\/strong> of the OSI model. Port numbers do not exist at Layer 3; they are a <strong>Layer 4 (Transport Layer)<\/strong> addressing mechanism used by TCP and UDP. If you run <code>ping example.com:443<\/code>, your operating system treats the entire string\u2014including the colon and port\u2014as a literal hostname and fails during DNS resolution.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_difference_between_an_ICMP_ping_and_a_TCP_port_ping\"><\/span>What is the difference between an ICMP ping and a TCP port ping?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>An ICMP ping tests host-level IP reachability between two network interfaces, assuming no firewall drops ICMP traffic along the path. A TCP port ping tests service-level reachability by targeting a specific port number (<code>1<\/code>\u2013<code>65535<\/code>) on the destination host, confirming both that firewall rules allow traffic on that port and that an application process is actively listening.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_does_TCP_handshake_probing_work_compared_to_standard_ping\"><\/span>How does TCP handshake probing work compared to standard ping?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Instead of sending an ICMP Echo Request, a TCP ping initiates a Layer 4 connection probe in one of two ways:<\/p>\n<ul>\n<li><strong>Full TCP Connect Probe:<\/strong> Standard OS utilities (<code>Test-NetConnection<\/code>, <code>nc<\/code>, <code>curl<\/code>, <code>telnet<\/code>) ask the operating system kernel to perform a complete three-way handshake (<code>SYN<\/code> \u2192 <code>SYN-ACK<\/code> \u2192 <code>ACK<\/code>). Once the target responds with <code>SYN-ACK<\/code> and the connection succeeds, the tool immediately closes the socket. This method requires no administrator privileges.<\/li>\n<li><strong>Half-Open TCP SYN Probe:<\/strong> Dedicated packet-crafting tools (<code>nmap -sS<\/code>, <code>hping3 -S<\/code>) send a raw <code>SYN<\/code> packet and measure the time until a <code>SYN-ACK<\/code> (open) or <code>RST<\/code> (closed) packet returns, sending a <code>RST<\/code> to tear down the attempt before completing the handshake. Crafting raw packets typically requires root or Administrator privileges.<\/li>\n<\/ul>\n<p>Because standard <code>ping<\/code> is limited to portless ICMP, testing a TCP port requires using a Layer 4 utility built into your operating system.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Ping_a_TCP_Port_on_Windows_PowerShell_and_CMD\"><\/span>How to Ping a TCP Port on Windows (PowerShell and CMD)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Modern versions of Windows 10, Windows 11, and Windows Server include built-in utilities in both PowerShell and Command Prompt (<code>cmd.exe<\/code>) to test TCP port reachability without downloading third-party tools.<\/p>\n<ol>\n<li><strong>Test a TCP port in PowerShell with <code>Test-NetConnection<\/code><\/strong><br \/>\n   Open PowerShell and run <code>Test-NetConnection<\/code> (or its built-in alias <code>tnc<\/code>) with the target hostname or IP address and port number:<\/li>\n<\/ol>\n<p><code>powershell<br \/>\n   Test-NetConnection -ComputerName example.com -Port 443<\/code><\/p>\n<p>Wait a moment for the probe to finish and inspect the <code>TcpTestSucceeded<\/code> field at the bottom of the output. <code>True<\/code> confirms the TCP three-way handshake completed; <code>False<\/code> indicates the port is unreachable.<\/p>\n<ol>\n<li><strong>Test a TCP port in Command Prompt (<code>cmd.exe<\/code>) using built-in <code>curl<\/code><\/strong><br \/>\n   Windows 10 (build 17063 and later) and Windows 11 ship with <code>curl.exe<\/code> pre-installed. You can force <code>curl<\/code> to perform a raw TCP handshake against <em>any<\/em> port\u2014not just HTTP\u2014by using the <code>telnet:\/\/<\/code> protocol prefix:<\/li>\n<\/ol>\n<p><code>cmd<br \/>\n   curl -v --connect-timeout 5 telnet:\/\/example.com:443<\/code><\/p>\n<p>Look for the line <code>* Connected to example.com (&lt;IP&gt;) port 443<\/code> in the verbose output. If the connection succeeds and stays open waiting for input, press <code>Ctrl+C<\/code> to disconnect.<\/p>\n<ol>\n<li><strong>Test interactively in CMD with the optional Windows Telnet Client<\/strong><br \/>\n   If you need to inspect a raw plain-text service banner (such as SMTP on port <code>25<\/code> or SSH on port <code>22<\/code>), enable the built-in Telnet client from an elevated Command Prompt and run <code>telnet<\/code> with a space\u2014not a colon\u2014between the host and port:<\/li>\n<\/ol>\n<p><code>cmd<br \/>\n   dism \/online \/Enable-Feature \/FeatureName:TelnetClient<br \/>\n   telnet example.com 443<\/code><\/p>\n<p>If the terminal clears to a blank screen or prints a service banner, the TCP port is open (press <code>Ctrl+]<\/code>, type <code>quit<\/code>, and press <code>Enter<\/code> to exit). An error reading <code>Could not open connection to the host<\/code> means the port is closed or blocked.<\/p>\n<p>While interactive <code>Test-NetConnection<\/code> checks work well for manual troubleshooting, automating port checks in PowerShell requires knowing its exact parameter sets and return types.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Microsoft_PowerShell_Test-NetConnection_Reference\"><\/span>Microsoft PowerShell Test-NetConnection Reference<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><code>Test-NetConnection<\/code> is the official diagnostic cmdlet in the Windows <code>NetTCPIP<\/code> module for testing TCP port connectivity, ICMP reachability, and routing paths.<\/p>\n<ul>\n<li><strong>Module:<\/strong> <code>NetTCPIP<\/code><\/li>\n<li><strong>Built-in Alias:<\/strong> <code>tnc<\/code><\/li>\n<li><strong>Platform Support:<\/strong> Windows PowerShell 5.1 and PowerShell 7+ on Windows<\/li>\n<li><strong>Official Documentation:<\/strong> <code>https:\/\/learn.microsoft.com\/powershell\/module\/nettcpip\/test-netconnection<\/code><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Syntax_TCP_Port_Parameter_Sets\"><\/span>Syntax (TCP Port Parameter Sets)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-powershell\">Test-NetConnection\n    [[-ComputerName] &lt;String&gt;]\n    [-Port &lt;Int32&gt;]\n    [-InformationLevel &lt;String&gt;]\n\nTest-NetConnection\n    [[-ComputerName] &lt;String&gt;]\n    -CommonTCPPort &lt;String&gt;\n    [-InformationLevel &lt;String&gt;]\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Parameters\"><\/span>Parameters<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong><code>-ComputerName &lt;String&gt;<\/code><\/strong>: Specifies the Domain Name System (DNS) name or IPv4\/IPv6 address of the target host. Accepts positional input at position <code>0<\/code>.<\/li>\n<li><strong><code>-Port &lt;Int32&gt;<\/code><\/strong>: Specifies the remote TCP port number (<code>1<\/code> through <code>65535<\/code>). Cannot be combined with <code>-CommonTCPPort<\/code>.<\/li>\n<li><strong><code>-CommonTCPPort &lt;String&gt;<\/code><\/strong>: Tests a predefined well-known service port by name instead of number. Accepted values are <code>HTTP<\/code> (<code>80<\/code>), <code>RDP<\/code> (<code>3389<\/code>), <code>SMB<\/code> (<code>445<\/code>), and <code>WINRM<\/code> (<code>5985<\/code>).<\/li>\n<li><strong><code>-InformationLevel &lt;String&gt;<\/code><\/strong>: Specifies the output verbosity and return type. Accepted values are <code>Detailed<\/code> and <code>Quiet<\/code>.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Return_Objects_and_Quiet_Mode\"><\/span>Return Objects and Quiet Mode<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>Default \/ <code>Detailed<\/code> Output:<\/strong> Returns a <code>NetRouteDiagnostics<\/code> (<code>TestNetConnectionResult<\/code>) object containing <code>ComputerName<\/code>, <code>RemoteAddress<\/code>, <code>RemotePort<\/code>, <code>InterfaceAlias<\/code>, <code>SourceAddress<\/code>, <code>TcpTestSucceeded<\/code> (<code>System.Boolean<\/code>), and fallback <code>PingSucceeded<\/code> properties. When a TCP test fails in default mode, the cmdlet automatically runs an ICMP ping and DNS lookup to populate diagnostic fields.<\/li>\n<li><strong><code>Quiet<\/code> Output:<\/strong> Suppresses the diagnostic object and returns a raw <code>System.Boolean<\/code> (<code>True<\/code> or <code>False<\/code>). On failure, PowerShell still writes a warning message unless suppressed:<\/li>\n<\/ul>\n<pre><code class=\"language-powershell\">Test-NetConnection -ComputerName 10.0.0.25 -Port 3389 -InformationLevel Quiet -WarningAction SilentlyContinue\n<\/code><\/pre>\n<p>If you are working from a Unix-based workstation or server instead of Windows, terminal utilities like Netcat and Nmap provide faster timeout control.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Ping_a_TCP_Port_on_Linux_and_macOS\"><\/span>How to Ping a TCP Port on Linux and macOS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Linux distributions and macOS include lightweight command-line tools that test TCP sockets with customizable connection timeouts.<\/p>\n<ol>\n<li>\n<p><strong>Probe a port quickly with Netcat (<code>nc<\/code>)<\/strong><br \/>\n   Netcat is pre-installed on macOS and most Linux distributions (such as Ubuntu). Pass <code>-z<\/code> (zero-I\/O mode, which closes the connection immediately after the handshake) and <code>-v<\/code> (verbose output), along with the platform-specific connection timeout flag:<\/p>\n<\/li>\n<li>\n<p><strong>On Linux<\/strong> (uses <code>-w<\/code> for connection timeout in seconds):<br \/>\n     <code>bash<br \/>\n     nc -zv -w 3 example.com 443<\/code><\/p>\n<\/li>\n<li><strong>On macOS<\/strong> (uses <code>-G<\/code> for TCP connection timeout; <code>-w<\/code> on macOS does not cap the initial <code>SYN<\/code> handshake wait):<br \/>\n     <code>bash<br \/>\n     nc -zv -G 3 example.com 443<\/code><\/li>\n<\/ol>\n<p>A <code>succeeded!<\/code> or <code>Connected to...<\/code> message confirms the port is open, and <code>nc<\/code> exits with status code <code>0<\/code>.<\/p>\n<ol>\n<li><strong>Distinguish port states with Nmap (<code>nmap<\/code>)<\/strong><br \/>\n   When installed (<code>sudo apt install nmap<\/code> or <code>brew install nmap<\/code>), Nmap reports whether a port is explicitly <code>open<\/code>, <code>closed<\/code>, or <code>filtered<\/code>. Always include <code>-Pn<\/code> to skip ICMP host discovery so Nmap still tests the TCP port even if the remote host blocks standard ping:<\/li>\n<\/ol>\n<p><code>bash<br \/>\n   nmap -Pn -p 443 example.com<\/code><\/p>\n<ol>\n<li><strong>Use <code>curl<\/code> when Netcat or Nmap is unavailable<\/strong><br \/>\n   Just as on Windows, <code>curl<\/code> with the <code>telnet:\/\/<\/code> scheme tests raw TCP connectivity on virtually any Linux or macOS machine:<\/li>\n<\/ol>\n<p><code>bash<br \/>\n   curl -v --connect-timeout 3 telnet:\/\/example.com:443<\/code><\/p>\n<ol>\n<li><strong>Grab service banners with <code>telnet<\/code><\/strong><br \/>\n   Because Apple removed <code>\/usr\/bin\/telnet<\/code> in modern macOS releases and minimal Linux servers often omit it, you may need to install it first (<code>brew install telnet<\/code> or <code>sudo apt install telnet<\/code>), then run <code>telnet example.com 443<\/code> for interactive testing.<\/li>\n<\/ol>\n<p>Running any of these commands on Windows, Linux, or macOS will either succeed immediately or fail with one of two distinct error messages that pinpoint where traffic is stopping.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Troubleshooting_Failed_Tests_Connection_Timed_Out_vs_Connection_Refused\"><\/span>Troubleshooting Failed Tests: Connection Timed Out vs. Connection Refused<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Not all failed TCP port pings mean the same thing. Comparing the exact error message tells you whether to investigate host services or network firewalls.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_difference_between_Connection_timed_out_and_Connection_refused\"><\/span>What is the difference between &#8220;Connection timed out&#8221; and &#8220;Connection refused&#8221;?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>Connection refused:<\/strong> Your <code>SYN<\/code> packet successfully crossed the network and passed through intermediate firewalls, but the destination OS actively rejected it with a <strong>TCP <code>RST<\/code> (Reset)<\/strong> packet. This almost always means the host is online and reachable, <strong>no service is listening on that port<\/strong>, or the service is bound only to <code>127.0.0.1<\/code> (localhost) rather than <code>0.0.0.0<\/code> or the host&#8217;s LAN IP.<\/li>\n<li><strong>Connection timed out:<\/strong> Your <code>SYN<\/code> packet received <strong>no response<\/strong> before the client timeout expired. A stateful firewall, cloud security group (such as an AWS Security Group or Azure NSG), network ACL, or host firewall is silently <strong>dropping<\/strong> the packet\u2014or a missing route prevents packets from arriving or returning.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"What_do_Open_Closed_and_Filtered_port_states_mean\"><\/span>What do Open, Closed, and Filtered port states mean?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Tools like Nmap classify TCP probe outcomes into three states that map directly to the handshake responses above:<\/p>\n<ul>\n<li><strong>Open:<\/strong> The target replied with <code>SYN-ACK<\/code>. An application is listening and firewalls permit traffic.<\/li>\n<li><strong>Closed:<\/strong> The target replied with <code>RST<\/code> (<em>Connection refused<\/em>). The host is reachable through the firewall, but nothing is listening on the port.<\/li>\n<li><strong>Filtered:<\/strong> No reply arrived before timeout, or an intermediate router returned an ICMP administratively prohibited message (<em>Connection timed out<\/em>). Packet filtering blocks the probe from reaching the port.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Why_does_a_TCP_port_ping_fail_when_standard_ICMP_ping_works\"><\/span>Why does a TCP port ping fail when standard ICMP ping works?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Firewalls and operating systems process Layer 3 ICMP rules independently of Layer 4 TCP ports. If standard <code>ping<\/code> works while your TCP port test fails, IP routing and host power state are healthy\u2014check whether the target daemon is running (if <em>refused<\/em>) or whether a firewall rule permits that specific TCP port (if <em>timed out<\/em>). Conversely, cloud instances frequently block ICMP Echo Requests by default while allowing ports like <code>80<\/code> and <code>443<\/code>, meaning a TCP port ping can succeed even when standard <code>ping<\/code> fails completely.<\/p>\n<p>While native OS tools reveal whether a port is open, closed, or filtered, they generally omit round-trip handshake timing in milliseconds. Dedicated CLI utilities fill that gap.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Best_TCP_Port_Ping_Tools_and_CLI_Utilities_Compared\"><\/span>Best TCP Port Ping Tools and CLI Utilities Compared<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When troubleshooting slow application responses or intermittent network glitches, third-party TCP ping utilities offer sub-millisecond timing, fast timeouts, and <code>ping<\/code>-like continuous output that built-in tools lack.<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Tool<\/th>\n<th style=\"text-align: left;\">OS Support<\/th>\n<th style=\"text-align: left;\">Setup Requirement<\/th>\n<th style=\"text-align: left;\">Millisecond Latency (RTT)<\/th>\n<th style=\"text-align: left;\">Continuous Mode (<code>-t<\/code> style)<\/th>\n<th style=\"text-align: left;\">Speed &amp; Best Use Case<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>Sysinternals PsPing<\/strong> (<code>psping<\/code>)<\/td>\n<td style=\"text-align: left;\">Windows<\/td>\n<td style=\"text-align: left;\">Standalone <code>.exe<\/code> download (no installer)<\/td>\n<td style=\"text-align: left;\">Yes (sub-ms precision + histograms)<\/td>\n<td style=\"text-align: left;\">Yes (<code>-t<\/code>)<\/td>\n<td style=\"text-align: left;\">Fast; best all-around TCP latency &amp; loss monitor on Windows<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>tcping<\/strong><\/td>\n<td style=\"text-align: left;\">Windows, Linux, macOS<\/td>\n<td style=\"text-align: left;\">Standalone <code>.exe<\/code> (Win) or package install<\/td>\n<td style=\"text-align: left;\">Yes (ms precision)<\/td>\n<td style=\"text-align: left;\">Yes (<code>-t<\/code> on Win; default on Unix)<\/td>\n<td style=\"text-align: left;\">Fast; closest drop-in syntax to standard <code>ping<\/code> over TCP<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Nmap<\/strong> (<code>nmap<\/code> \/ <code>nping<\/code>)<\/td>\n<td style=\"text-align: left;\">Windows, Linux, macOS<\/td>\n<td style=\"text-align: left;\">Installer \/ package manager<\/td>\n<td style=\"text-align: left;\">Yes (host RTT &amp; <code>nping<\/code> probe RTT)<\/td>\n<td style=\"text-align: left;\">Via bundled <code>nping -c 0<\/code><\/td>\n<td style=\"text-align: left;\">Fast; best for distinguishing <code>open<\/code>, <code>closed<\/code>, and <code>filtered<\/code> states<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>hping3<\/strong><\/td>\n<td style=\"text-align: left;\">Linux, macOS, Unix<\/td>\n<td style=\"text-align: left;\">Package manager + <code>root<\/code>\/<code>sudo<\/code><\/td>\n<td style=\"text-align: left;\">Yes (ms precision)<\/td>\n<td style=\"text-align: left;\">Yes (default 1 pkt\/sec)<\/td>\n<td style=\"text-align: left;\">Fast; best for raw <code>SYN<\/code>\/<code>ACK<\/code> flag crafting and firewall auditing<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Test-NetConnection<\/strong> (<code>tnc<\/code>)<\/td>\n<td style=\"text-align: left;\">Windows<\/td>\n<td style=\"text-align: left;\">Built-in (PowerShell)<\/td>\n<td style=\"text-align: left;\">No<\/td>\n<td style=\"text-align: left;\">No<\/td>\n<td style=\"text-align: left;\">Slow on failures (15\u201320s wait + fallback ICMP); best for zero-setup checks<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Netcat<\/strong> (<code>nc<\/code>)<\/td>\n<td style=\"text-align: left;\">Linux, macOS<\/td>\n<td style=\"text-align: left;\">Built-in on macOS &amp; most Linux distros<\/td>\n<td style=\"text-align: left;\">No<\/td>\n<td style=\"text-align: left;\">No<\/td>\n<td style=\"text-align: left;\">Instant with <code>-w<\/code>\/<code>-G<\/code> timeout; best for quick one-shot scripting<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Telnet<\/strong><\/td>\n<td style=\"text-align: left;\">Windows, Linux, macOS<\/td>\n<td style=\"text-align: left;\">Optional feature (Win) \/ package install<\/td>\n<td style=\"text-align: left;\">No<\/td>\n<td style=\"text-align: left;\">No<\/td>\n<td style=\"text-align: left;\">Manual exit required; best only for interactive plain-text banner checks<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Choose built-in <code>Test-NetConnection<\/code> or <code>nc<\/code> when you cannot install software and only need a pass\/fail answer. Reach for <code>PsPing<\/code>, <code>tcping<\/code>, <code>nping<\/code>, or <code>hping3<\/code> whenever you need millisecond handshake latency or repeated probing.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Continuously_Ping_a_TCP_Port_to_Monitor_Latency_and_Drops\"><\/span>How to Continuously Ping a TCP Port to Monitor Latency and Drops<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Intermittent packet loss, load-balancer hiccups, and firewall state-table exhaustion rarely show up in a single test. Running a persistent TCP probe lets you track round-trip handshake latency in milliseconds and spot drops in real time.<\/p>\n<ol>\n<li><strong>Monitor continuously on Windows with <code>PsPing<\/code> or <code>tcping<\/code><\/strong><br \/>\n   Download Microsoft Sysinternals <code>psping.exe<\/code> (or <code>tcping.exe<\/code>) and pass the <code>-t<\/code> flag to probe once per second until you press <code>Ctrl+C<\/code>:<\/li>\n<\/ol>\n<p><code>cmd<br \/>\n   psping -t 192.168.1.50:443<\/code><\/p>\n<p><code>PsPing<\/code> prints exact millisecond connect latency for each iteration and outputs minimum, maximum, average, and packet-loss statistics on exit. (With <code>tcping<\/code>, separate the host and port with a space: <code>tcping -t example.com 443<\/code>.)<\/p>\n<ol>\n<li><strong>Monitor continuously on Windows without third-party tools (PowerShell)<\/strong><br \/>\n   As noted in the comparison table above, looping <code>Test-NetConnection<\/code> is unsuitable for latency monitoring because it neither reports TCP RTT nor allows short timeouts. Instead, use <code>.NET<\/code>&#8216;s <code>TcpClient<\/code> paired with <code>Stopwatch<\/code> in PowerShell:<\/li>\n<\/ol>\n<p>&#8220;`powershell<br \/>\n   $Target = &#8220;example.com&#8221;<br \/>\n   $Port = 443<br \/>\n   $TimeoutMs = 2000<\/p>\n<p>while ($true) {<br \/>\n       $Client = [System.Net.Sockets.TcpClient]::new()<br \/>\n       $Sw = [System.Diagnostics.Stopwatch]::StartNew()<br \/>\n       try {<br \/>\n           if ($Client.ConnectAsync($Target, $Port).Wait($TimeoutMs) -and $Client.Connected) {<br \/>\n               $Sw.Stop()<br \/>\n               Write-Host &#8220;$(Get-Date -Format &#8216;HH:mm:ss&#8217;) &#8211; Connected to ${Target}:${Port} time=$([math]::Round($Sw.Elapsed.TotalMilliseconds, 2))ms&#8221;<br \/>\n           } else {<br \/>\n               Write-Host &#8220;$(Get-Date -Format &#8216;HH:mm:ss&#8217;) &#8211; Request timed out (${Target}:${Port})&#8221; -ForegroundColor Yellow<br \/>\n           }<br \/>\n       } catch {<br \/>\n           Write-Host &#8220;$(Get-Date -Format &#8216;HH:mm:ss&#8217;) &#8211; Failed: $($_.Exception.GetBaseException().Message)&#8221; -ForegroundColor Red<br \/>\n       } finally {<br \/>\n           $Client.Close()<br \/>\n       }<br \/>\n       Start-Sleep -Seconds 1<br \/>\n   }<br \/>\n   &#8220;`<\/p>\n<ol>\n<li><strong>Monitor continuously on Linux and macOS with <code>hping3<\/code> or <code>nping<\/code><\/strong><br \/>\n   If you have root privileges and <code>hping3<\/code> installed, send continuous half-open <code>SYN<\/code> probes (<code>-S<\/code>). Otherwise, use <code>nping<\/code> (bundled with Nmap) in unprivileged <code>--tcp-connect<\/code> mode with <code>-c 0<\/code> to run indefinitely:<\/li>\n<\/ol>\n<p>&#8220;`bash<br \/>\n   # Raw TCP SYN ping (requires sudo)<br \/>\n   sudo hping3 -S -p 443 example.com<\/p>\n<p># Unprivileged continuous TCP connect ping (bundled with Nmap)<br \/>\n   nping &#8211;tcp-connect -p 443 -c 0 &#8211;delay 1s example.com<br \/>\n   &#8220;`<\/p>\n<ol>\n<li><strong>Monitor continuously on Linux and macOS with zero extra packages (Python 3)<\/strong><br \/>\n   When neither <code>hping3<\/code> nor <code>nping<\/code> is installed, run a Python 3 <code>socket<\/code> loop using <code>time.perf_counter()<\/code> for sub-millisecond precision:<\/li>\n<\/ol>\n<p><code>bash<br \/>\n   python3 -c '<br \/>\n   import socket, time<br \/>\n   host, port = \"example.com\", 443<br \/>\n   while True:<br \/>\n       ts, t0 = time.strftime(\"%H:%M:%S\"), time.perf_counter()<br \/>\n       try:<br \/>\n           with socket.create_connection((host, port), timeout=2):<br \/>\n               print(f\"{ts} - {host}:{port} time={(time.perf_counter()-t0)*1000:.2f}ms\")<br \/>\n       except OSError as e:<br \/>\n           print(f\"{ts} - {host}:{port} failed ({e})\")<br \/>\n       time.sleep(1)<br \/>\n   '<\/code><\/p>\n<p>Sometimes even standard shell utilities like <code>nc<\/code>, <code>curl<\/code>, and <code>ping<\/code> are completely absent\u2014most commonly inside minimal container images.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Pinging_a_TCP_Port_in_Docker_Containers_and_Kubernetes_Pods_Without_Netcat\"><\/span>Pinging a TCP Port in Docker Containers and Kubernetes Pods Without Netcat<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Minimal Docker images and locked-down Kubernetes pods rarely include <code>nc<\/code>, <code>telnet<\/code>, or <code>nmap<\/code>. Replace <code>&lt;HOST&gt;<\/code>, <code>&lt;PORT&gt;<\/code>, and <code>&lt;POD_NAME&gt;<\/code> or <code>&lt;CONTAINER_NAME&gt;<\/code> in the one-liners below to test TCP reachability using built-in shell or runtime primitives.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Bash_devtcp_Pseudo-Device_Containers_with_binbash\"><\/span>Bash <code>\/dev\/tcp<\/code> Pseudo-Device (Containers with <code>\/bin\/bash<\/code>)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\">kubectl exec &lt;POD_NAME&gt; -- timeout 3 bash -c &quot;&lt;\/dev\/tcp\/&lt;HOST&gt;\/&lt;PORT&gt;&quot; &amp;&amp; echo &quot;OPEN&quot; || echo &quot;CLOSED_OR_FILTERED&quot;\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Python_3_Socket_One-Liner_Supports_IPv4_IPv6_and_Cluster_DNS\"><\/span>Python 3 Socket One-Liner (Supports IPv4, IPv6, and Cluster DNS)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\">kubectl exec &lt;POD_NAME&gt; -- python3 -c 'import socket; s = socket.create_connection((&quot;&lt;HOST&gt;&quot;, &lt;PORT&gt;), timeout=3); s.close(); print(&quot;OPEN&quot;)'\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Nodejs_net_One-Liner_Slim_Node_Microservice_Containers\"><\/span>Node.js <code>net<\/code> One-Liner (Slim Node Microservice Containers)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\">docker exec &lt;CONTAINER_NAME&gt; node -e 'const s = require(&quot;net&quot;).connect(&lt;PORT&gt;, &quot;&lt;HOST&gt;&quot;, () =&gt; { console.log(&quot;OPEN&quot;); s.end(); }); s.setTimeout(3000, () =&gt; { console.error(&quot;TIMEOUT&quot;); s.destroy(); process.exit(1); }); s.on(&quot;error&quot;, (e) =&gt; { console.error(e.code); process.exit(1); });'\n<\/code><\/pre>\n<p>When validating an entire environment migration or new firewall rule matrix, testing ports one host at a time becomes impractical\u2014batch scripts let you verify dozens of endpoints in seconds.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"PowerShell_and_Bash_Script_Templates_to_Ping_Multiple_TCP_Ports\"><\/span>PowerShell and Bash Script Templates to Ping Multiple TCP Ports<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Use the templates below to batch-test TCP port connectivity across multiple servers and ports with bounded timeouts.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"PowerShell_Bulk_TCP_Port_Test_Script_Inline_or_CSV_Input\"><\/span>PowerShell Bulk TCP Port Test Script (Inline or CSV Input)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Save as <code>Test-TcpPorts.ps1<\/code>. It reads <code>targets.csv<\/code> (columns: <code>Host,Ports<\/code>) if present in the current directory, or falls back to the inline <code>$Targets<\/code> list:<\/p>\n<pre><code class=\"language-powershell\"># Optional CSV file format (.\\targets.csv):\n# Host,Ports\n# 10.0.1.10,&quot;80,443,3389&quot;\n# db01.internal,&quot;5432&quot;\n\n$CsvPath = &quot;.\\targets.csv&quot;\n$TimeoutMs = 1500\n\n$Targets = if (Test-Path $CsvPath) {\n    Import-Csv -Path $CsvPath\n} else {\n    @(\n        [PSCustomObject]@{ Host = &quot;10.0.1.10&quot;; Ports = &quot;22,80,443&quot; }\n        [PSCustomObject]@{ Host = &quot;10.0.1.20&quot;; Ports = &quot;3389,5432&quot; }\n    )\n}\n\n$Results = foreach ($Row in $Targets) {\n    foreach ($RawPort in ($Row.Ports -split ',')) {\n        $Port = [int]$RawPort.Trim()\n        $Client = [System.Net.Sockets.TcpClient]::new()\n        $Status = try {\n            if ($Client.ConnectAsync($Row.Host, $Port).Wait($TimeoutMs) -and $Client.Connected) {\n                &quot;Open&quot;\n            } else {\n                &quot;TimedOut&quot;\n            }\n        } catch {\n            $Err = $_.Exception.GetBaseException()\n            if ($Err -is [System.Net.Sockets.SocketException]) {\n                &quot;Closed ($($Err.SocketErrorCode))&quot;\n            } else {\n                &quot;Error ($($Err.Message))&quot;\n            }\n        } finally {\n            $Client.Close()\n        }\n\n        [PSCustomObject]@{\n            Host   = $Row.Host\n            Port   = $Port\n            Status = $Status\n        }\n    }\n}\n\n$Results | Format-Table -AutoSize\n# Uncomment to export results to CSV:\n# $Results | Export-Csv -Path &quot;.\\port-test-report.csv&quot; -NoTypeInformation\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Bash_Bulk_TCP_Port_Test_Script_Linux_and_macOS\"><\/span>Bash Bulk TCP Port Test Script (Linux and macOS)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Save as <code>check-ports.sh<\/code> and run <code>chmod +x check-ports.sh<\/code>. Pass an optional text file containing one <code>host:port<\/code> entry per line (<code>.\/check-ports.sh targets.txt<\/code>), or edit <code>DEFAULT_TARGETS<\/code> inline:<\/p>\n<pre><code class=\"language-bash\">#!\/usr\/bin\/env bash\n# Usage: .\/check-ports.sh [targets.txt]\n\nTIMEOUT=2\nNC_TIMEOUT_FLAG=&quot;-w&quot;\n[[ &quot;$(uname -s)&quot; == &quot;Darwin&quot; ]] &amp;&amp; NC_TIMEOUT_FLAG=&quot;-G&quot;\n\nDEFAULT_TARGETS=(\n  &quot;10.0.1.10:22&quot;\n  &quot;10.0.1.10:443&quot;\n  &quot;10.0.1.20:5432&quot;\n)\n\nif [[ -n &quot;${1:-}&quot; &amp;&amp; -f &quot;$1&quot; ]]; then\n  TARGETS=()\n  while IFS= read -r line || [[ -n &quot;$line&quot; ]]; do\n    [[ &quot;$line&quot; =~ ^[[:space:]]*(#|$) ]] &amp;&amp; continue\n    TARGETS+=(&quot;$line&quot;)\n  done &lt; &quot;$1&quot;\nelse\n  TARGETS=(&quot;${DEFAULT_TARGETS[@]}&quot;)\nfi\n\nprintf &quot;%-25s %-8s %-12s\\n&quot; &quot;HOST&quot; &quot;PORT&quot; &quot;STATUS&quot;\nprintf &quot;%-25s %-8s %-12s\\n&quot; &quot;----&quot; &quot;----&quot; &quot;------&quot;\n\nfor entry in &quot;${TARGETS[@]}&quot;; do\n  host=&quot;${entry%:*}&quot;\n  port=&quot;${entry##*:}&quot;\n  if nc -z &quot;$NC_TIMEOUT_FLAG&quot; &quot;$TIMEOUT&quot; &quot;$host&quot; &quot;$port&quot; &gt;\/dev\/null 2&gt;&amp;1; then\n    status=&quot;OPEN&quot;\n  else\n    status=&quot;UNREACHABLE&quot;\n  fi\n  printf &quot;%-25s %-8s %-12s\\n&quot; &quot;$host&quot; &quot;$port&quot; &quot;$status&quot;\ndone\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Testing whether a remote service is reachable means moving past Layer 3 ICMP <code>ping<\/code> and probing the target TCP port directly at Layer 4. For quick one-off checks, built-in commands like <code>Test-NetConnection<\/code> and <code>curl<\/code> on Windows or <code>nc -zv<\/code> on Linux and macOS confirm connectivity in seconds, while the distinction between <em>Connection refused<\/em> and <em>Connection timed out<\/em> immediately separates stopped application daemons from silent firewall drops. When troubleshooting deeper stability issues or auditing infrastructure at scale, pair dedicated utilities like <code>PsPing<\/code>, <code>tcping<\/code>, or <code>hping3<\/code> for millisecond latency tracking with socket-based scripts and container one-liners to validate connectivity across any environment.<\/p>\n<div class='sfsi_Sicons' style='width: 100%; display: inline-block; vertical-align: middle; text-align:left'><div style='margin:0px 8px 0px 0px; line-height: 24px'><span>Please follow and like us:<\/span><\/div><div class='sfsi_socialwpr'><div class='sf_fb_share sf_icon' style='text-align:left;vertical-align: middle;'><a href='https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fcciedump.spoto.net%2Fblog%2Fhow-to-ping-a-tcp-port_25451.html' style='display:inline-block;'  > <img class='sfsi_wicon'  data-pin-nopin='true' width='auto' height='auto' alt='fb-share-icon' title='Facebook Share' src='https:\/\/cciedump.spoto.net\/blog\/wp-content\/plugins\/ultimate-social-media-icons\/images\/visit_icons\/fbshare_bck.png'  \/><\/a><\/div><div class='sf_twiter sf_icon' style='display: inline-block;vertical-align: middle;width: auto;margin-left: 7px;'>\r\n\t\t\t\t\t\t<a target='_blank' href='https:\/\/twitter.com\/intent\/tweet?text=How+to+Ping+a+TCP+Port+https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html'style='display:inline-block' >\r\n\t\t\t\t\t\t\t<img data-pin-nopin= true width='auto' class='sfsi_wicon' src='https:\/\/cciedump.spoto.net\/blog\/wp-content\/plugins\/ultimate-social-media-icons\/images\/visit_icons\/en_US_Tweet.svg' alt='Tweet' title='Tweet' >\r\n\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t<\/div><div class='sf_pinit sf_icon' style='text-align:left;vertical-align: middle;float:left;line-height: 33px;width:auto;margin: 0 -2px;'><a href='#'  onclick='sfsi_pinterest_modal_images(event,\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\",\"How to Ping a TCP Port\")' style='display:inline-block;'  > <img class='sfsi_wicon'  data-pin-nopin='true' width='auto' height='auto' alt='fb-share-icon' title='Pin Share' src='https:\/\/cciedump.spoto.net\/blog\/wp-content\/plugins\/ultimate-social-media-icons\/images\/share_icons\/Pinterest_Save\/en_US_save.svg'  \/><\/a><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>When a web server, database, or remote desktop session fails to respond, running a standard ping only tells you whether the remote machine is online\u2014not whether the specific service port is open and accepting connections. Checking a specific port requires &#8220;pinging&#8221; over TCP to verify that packets can traverse intermediate firewalls and complete a handshake&#8230; &raquo; <a class=\"read-more-link\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\">read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":25450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1285],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Ping a TCP Port - SPOTO Official Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Ping a TCP Port - SPOTO Official Blog\" \/>\n<meta property=\"og:description\" content=\"When a web server, database, or remote desktop session fails to respond, running a standard ping only tells you whether the remote machine is online\u2014not whether the specific service port is open and accepting connections. Checking a specific port requires &#8220;pinging&#8221; over TCP to verify that packets can traverse intermediate firewalls and complete a handshake... &raquo; read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\" \/>\n<meta property=\"og:site_name\" content=\"SPOTO Official Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-12-03T13:47:47+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"SPOTO \u7f16\u8f91\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638\",\"name\":\"SPOTO Club\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2020\/03\/spoto-facemask-96x96.jpg\",\"contentUrl\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2020\/03\/spoto-facemask-96x96.jpg\",\"caption\":\"SPOTO Club\"},\"logo\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#personlogo\"},\"description\":\"SPOTO is an excellent leader in IT certification training for 20+ years. We offer 100% real Cisco CCNA, CCNP exam dumps, CCIE Lab study materials, PMP, CISA, CISM, AWS, Palo Alto, and other IT exam dumps. We have helped thousands of candidates around the world to pass their IT exams on the first try! As the first-class online IT training organization in China, SPOTO cooperates with many giant Internet companies in China like Tencent, Baidu, and Alibaba. What\u2019s more, we have won lots of awards in IT education training such as \u201cTop Ten Influential Brands In Online Education Industry\u201d given by Baidu, \u201cOfficial IT Online Training Organization\u201d awarded by Tencent Class, etc. Join us: https:\/\/cciedump.spoto.net\/ Contact us: E-mail: support@spoto.net Phone \/ WhatsApp: +86 18344981205\",\"sameAs\":[\"https:\/\/cciedump.spoto.net\/\"]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#website\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/\",\"name\":\"SPOTO Official Blog\",\"description\":\"Focus on Online IT Training for 20+ Years\",\"publisher\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cciedump.spoto.net\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-ping-a-tcp-port.png\",\"contentUrl\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-ping-a-tcp-port.png\",\"width\":1024,\"height\":768,\"caption\":\"How to Ping a TCP Port\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#webpage\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\",\"name\":\"How to Ping a TCP Port - SPOTO Official Blog\",\"isPartOf\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#primaryimage\"},\"datePublished\":\"2026-12-03T13:47:47+00:00\",\"dateModified\":\"2026-12-03T13:47:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cciedump.spoto.net\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Ping a TCP Port\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#webpage\"},\"author\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/4edd6074d9632c14eda17a2205a88dd1\"},\"headline\":\"How to Ping a TCP Port\",\"datePublished\":\"2026-12-03T13:47:47+00:00\",\"dateModified\":\"2026-12-03T13:47:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#webpage\"},\"wordCount\":2242,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638\"},\"image\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-ping-a-tcp-port.png\",\"articleSection\":[\"Routing &amp; Switching\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/4edd6074d9632c14eda17a2205a88dd1\",\"name\":\"SPOTO \u7f16\u8f91\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/litespeed\/avatar\/f525ded90e4ff384a19ebdbe47c80d22.jpg?ver=1795769814\",\"contentUrl\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/litespeed\/avatar\/f525ded90e4ff384a19ebdbe47c80d22.jpg?ver=1795769814\",\"caption\":\"SPOTO \u7f16\u8f91\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Ping a TCP Port - SPOTO Official Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html","og_locale":"en_US","og_type":"article","og_title":"How to Ping a TCP Port - SPOTO Official Blog","og_description":"When a web server, database, or remote desktop session fails to respond, running a standard ping only tells you whether the remote machine is online\u2014not whether the specific service port is open and accepting connections. Checking a specific port requires &#8220;pinging&#8221; over TCP to verify that packets can traverse intermediate firewalls and complete a handshake... &raquo; read more","og_url":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html","og_site_name":"SPOTO Official Blog","article_published_time":"2026-12-03T13:47:47+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"SPOTO \u7f16\u8f91","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Person","Organization"],"@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638","name":"SPOTO Club","image":{"@type":"ImageObject","@id":"https:\/\/cciedump.spoto.net\/blog\/#personlogo","inLanguage":"en-US","url":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2020\/03\/spoto-facemask-96x96.jpg","contentUrl":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2020\/03\/spoto-facemask-96x96.jpg","caption":"SPOTO Club"},"logo":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#personlogo"},"description":"SPOTO is an excellent leader in IT certification training for 20+ years. We offer 100% real Cisco CCNA, CCNP exam dumps, CCIE Lab study materials, PMP, CISA, CISM, AWS, Palo Alto, and other IT exam dumps. We have helped thousands of candidates around the world to pass their IT exams on the first try! As the first-class online IT training organization in China, SPOTO cooperates with many giant Internet companies in China like Tencent, Baidu, and Alibaba. What\u2019s more, we have won lots of awards in IT education training such as \u201cTop Ten Influential Brands In Online Education Industry\u201d given by Baidu, \u201cOfficial IT Online Training Organization\u201d awarded by Tencent Class, etc. Join us: https:\/\/cciedump.spoto.net\/ Contact us: E-mail: support@spoto.net Phone \/ WhatsApp: +86 18344981205","sameAs":["https:\/\/cciedump.spoto.net\/"]},{"@type":"WebSite","@id":"https:\/\/cciedump.spoto.net\/blog\/#website","url":"https:\/\/cciedump.spoto.net\/blog\/","name":"SPOTO Official Blog","description":"Focus on Online IT Training for 20+ Years","publisher":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cciedump.spoto.net\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#primaryimage","inLanguage":"en-US","url":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-ping-a-tcp-port.png","contentUrl":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-ping-a-tcp-port.png","width":1024,"height":768,"caption":"How to Ping a TCP Port"},{"@type":"WebPage","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#webpage","url":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html","name":"How to Ping a TCP Port - SPOTO Official Blog","isPartOf":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#primaryimage"},"datePublished":"2026-12-03T13:47:47+00:00","dateModified":"2026-12-03T13:47:47+00:00","breadcrumb":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cciedump.spoto.net\/blog"},{"@type":"ListItem","position":2,"name":"How to Ping a TCP Port"}]},{"@type":"Article","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#article","isPartOf":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#webpage"},"author":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/4edd6074d9632c14eda17a2205a88dd1"},"headline":"How to Ping a TCP Port","datePublished":"2026-12-03T13:47:47+00:00","dateModified":"2026-12-03T13:47:47+00:00","mainEntityOfPage":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#webpage"},"wordCount":2242,"commentCount":0,"publisher":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638"},"image":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#primaryimage"},"thumbnailUrl":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-ping-a-tcp-port.png","articleSection":["Routing &amp; Switching"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cciedump.spoto.net\/blog\/how-to-ping-a-tcp-port_25451.html#respond"]}]},{"@type":"Person","@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/4edd6074d9632c14eda17a2205a88dd1","name":"SPOTO \u7f16\u8f91","image":{"@type":"ImageObject","@id":"https:\/\/cciedump.spoto.net\/blog\/#personlogo","inLanguage":"en-US","url":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/litespeed\/avatar\/f525ded90e4ff384a19ebdbe47c80d22.jpg?ver=1795769814","contentUrl":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/litespeed\/avatar\/f525ded90e4ff384a19ebdbe47c80d22.jpg?ver=1795769814","caption":"SPOTO \u7f16\u8f91"}}]}},"_links":{"self":[{"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/posts\/25451"}],"collection":[{"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/comments?post=25451"}],"version-history":[{"count":0,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/posts\/25451\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/media\/25450"}],"wp:attachment":[{"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/media?parent=25451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/categories?post=25451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/tags?post=25451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}