{"id":25453,"date":"2026-12-03T22:03:13","date_gmt":"2026-12-03T14:03:13","guid":{"rendered":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html"},"modified":"2026-12-03T22:03:13","modified_gmt":"2026-12-03T14:03:13","slug":"how-to-find-tcp-port-number","status":"publish","type":"post","link":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html","title":{"rendered":"How to Find TCP Port Number"},"content":{"rendered":"<p>Locating the exact TCP port number behind a network service or active connection is a routine necessity when troubleshooting port binding conflicts, writing firewall rules, auditing server exposure, or integrating unfamiliar hardware onto a LAN. Depending on whether you have local shell access, are probing a remote IP across the network, or need to catch a fleeting connection on the wire, the right discovery method changes. The sections below walk through how TCP port numbering works, where to look up authoritative protocol assignments, and how to identify active TCP ports across local operating systems, remote targets, packet captures, GUI scanners, and automated enterprise scripts.<\/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-find-tcp-port-number_25453.html\/#Understanding_TCP_Port_Numbers_and_Common_Default_Ports\" title=\"Understanding TCP Port Numbers and Common Default Ports\">Understanding TCP Port Numbers and Common Default Ports<\/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-find-tcp-port-number_25453.html\/#What_is_a_TCP_port_number_and_how_does_it_work\" title=\"What is a TCP port number and how does it work?\">What is a TCP port number and how does it work?<\/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-find-tcp-port-number_25453.html\/#How_do_well-known_registered_and_ephemeral_TCP_port_ranges_differ\" title=\"How do well-known, registered, and ephemeral TCP port ranges differ?\">How do well-known, registered, and ephemeral TCP port ranges differ?<\/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-find-tcp-port-number_25453.html\/#What_is_the_difference_between_TCP_and_UDP_port_numbers\" title=\"What is the difference between TCP and UDP port numbers?\">What is the difference between TCP and UDP port numbers?<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#What_are_the_most_common_default_TCP_port_numbers\" title=\"What are the most common default TCP port numbers?\">What are the most common default TCP port numbers?<\/a><\/li><\/ul><\/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-find-tcp-port-number_25453.html\/#Authoritative_Port_Lookup_The_IANA_Service_Name_and_Port_Number_Registry\" title=\"Authoritative Port Lookup: The IANA Service Name and Port Number Registry\">Authoritative Port Lookup: The IANA Service Name and Port Number Registry<\/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-find-tcp-port-number_25453.html\/#Official_Registry_Endpoints_and_Local_Mirrors\" title=\"Official Registry Endpoints and Local Mirrors\">Official Registry Endpoints and Local Mirrors<\/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-find-tcp-port-number_25453.html\/#Registry_Record_Schema\" title=\"Registry Record Schema\">Registry Record Schema<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#How_to_Find_Active_and_Listening_TCP_Ports_in_Windows\" title=\"How to Find Active and Listening TCP Ports in Windows\">How to Find Active and Listening TCP Ports in Windows<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Method_1_Command_Prompt_netstat_and_tasklist\" title=\"Method 1: Command Prompt (netstat and tasklist)\">Method 1: Command Prompt (netstat and tasklist)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Method_2_PowerShell_Get-NetTCPConnection\" title=\"Method 2: PowerShell (Get-NetTCPConnection)\">Method 2: PowerShell (Get-NetTCPConnection)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Method_3_Windows_Resource_Monitor_GUI\" title=\"Method 3: Windows Resource Monitor (GUI)\">Method 3: Windows Resource Monitor (GUI)<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#How_to_Audit_Listening_TCP_Ports_and_Daemons_in_Linux\" title=\"How to Audit Listening TCP Ports and Daemons in Linux\">How to Audit Listening TCP Ports and Daemons in Linux<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Step_1_Audit_Listening_TCP_Sockets_with_ss\" title=\"Step 1: Audit Listening TCP Sockets with ss\">Step 1: Audit Listening TCP Sockets with ss<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Step_2_Find_TCP_Ports_by_Process_ID_or_Port_Number_with_lsof\" title=\"Step 2: Find TCP Ports by Process ID or Port Number with lsof\">Step 2: Find TCP Ports by Process ID or Port Number with lsof<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Step_3_Fallback_Check_with_Legacy_netstat\" title=\"Step 3: Fallback Check with Legacy netstat\">Step 3: Fallback Check with Legacy netstat<\/a><\/li><\/ul><\/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-find-tcp-port-number_25453.html\/#How_to_Scan_and_Discover_Open_TCP_Ports_on_a_Remote_IP_Address\" title=\"How to Scan and Discover Open TCP Ports on a Remote IP Address\">How to Scan and Discover Open TCP Ports on a Remote IP Address<\/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-find-tcp-port-number_25453.html\/#Step_1_Test_a_Single_Known_Remote_TCP_Port\" title=\"Step 1: Test a Single Known Remote TCP Port\">Step 1: Test a Single Known Remote TCP Port<\/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-find-tcp-port-number_25453.html\/#Step_2_Scan_Common_Server_Ports_with_Nmap\" title=\"Step 2: Scan Common Server Ports with Nmap\">Step 2: Scan Common Server Ports with Nmap<\/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-find-tcp-port-number_25453.html\/#Step_3_Discover_Hardware_and_Non-Standard_Ports_Printers_Routers_Appliances\" title=\"Step 3: Discover Hardware and Non-Standard Ports (Printers, Routers, Appliances)\">Step 3: Discover Hardware and Non-Standard Ports (Printers, Routers, Appliances)<\/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-find-tcp-port-number_25453.html\/#Capturing_Short-Lived_or_Unknown_TCP_Ports_with_Wireshark_and_tcpdump\" title=\"Capturing Short-Lived or Unknown TCP Ports with Wireshark and tcpdump\">Capturing Short-Lived or Unknown TCP Ports with Wireshark and tcpdump<\/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-find-tcp-port-number_25453.html\/#Step_1_Start_a_Scoped_Capture_in_Wireshark\" title=\"Step 1: Start a Scoped Capture in Wireshark\">Step 1: Start a Scoped Capture in Wireshark<\/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-find-tcp-port-number_25453.html\/#Step_2_Apply_Wireshark_Display_Filters_to_Isolate_TCP_Ports\" title=\"Step 2: Apply Wireshark Display Filters to Isolate TCP Ports\">Step 2: Apply Wireshark Display Filters to Isolate TCP Ports<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Step_3_Read_Header_Fields_and_Conversation_Summaries\" title=\"Step 3: Read Header Fields and Conversation Summaries\">Step 3: Read Header Fields and Conversation Summaries<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Step_4_Inspect_TCP_Ports_on_Headless_Hosts_with_tcpdump\" title=\"Step 4: Inspect TCP Ports on Headless Hosts with tcpdump\">Step 4: Inspect TCP Ports on Headless Hosts with tcpdump<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Comparing_Dedicated_TCP_Port_Scanners_and_GUI_Socket_Viewers\" title=\"Comparing Dedicated TCP Port Scanners and GUI Socket Viewers\">Comparing Dedicated TCP Port Scanners and GUI Socket Viewers<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Ready-to-Use_PowerShell_and_Python_TCP_Port_Audit_Scripts\" title=\"Ready-to-Use PowerShell and Python TCP Port Audit Scripts\">Ready-to-Use PowerShell and Python TCP Port Audit Scripts<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#PowerShell_Multi-Host_TCP_Port_Scanner_Invoke-TcpPortAuditps1\" title=\"PowerShell Multi-Host TCP Port Scanner (Invoke-TcpPortAudit.ps1)\">PowerShell Multi-Host TCP Port Scanner (Invoke-TcpPortAudit.ps1)<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Cross-Platform_Python_3_Concurrent_TCP_Port_Scanner_tcp_port_auditpy\" title=\"Cross-Platform Python 3 Concurrent TCP Port Scanner (tcp_port_audit.py)\">Cross-Platform Python 3 Concurrent TCP Port Scanner (tcp_port_audit.py)<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Understanding_TCP_Port_Numbers_and_Common_Default_Ports\"><\/span>Understanding TCP Port Numbers and Common Default Ports<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"What_is_a_TCP_port_number_and_how_does_it_work\"><\/span>What is a TCP port number and how does it work?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>A TCP port number is a 16-bit unsigned integer ranging from <code>0<\/code> to <code>65535<\/code> embedded in the Transmission Control Protocol header of every segment. While an IP address routes traffic to a specific host, the TCP port number identifies the exact application process or daemon socket on that host. Combined, an IP address and a TCP port form a socket pair (<code>IP:Port<\/code>), allowing a single machine to run web servers, database engines, and remote administration daemons simultaneously without mixing traffic streams.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_well-known_registered_and_ephemeral_TCP_port_ranges_differ\"><\/span>How do well-known, registered, and ephemeral TCP port ranges differ?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Under IETF RFC 6335, the 65,536 possible TCP port numbers are divided into three distinct operational tiers:<\/p>\n<ul>\n<li><strong>Well-Known \/ System Ports (<code>0\u20131023<\/code>):<\/strong> Reserved for core internet protocols and privileged OS daemons. On Unix-like systems and modern Windows configurations, binding a listener in this range typically requires root or administrative privileges. Port <code>0<\/code> is reserved as a programming wildcard that instructs the operating system kernel to allocate any available port dynamically.<\/li>\n<li><strong>Registered \/ User Ports (<code>1024\u201349151<\/code>):<\/strong> Assigned to vendor applications, database servers, message brokers, and middleware frameworks that run under standard user accounts.<\/li>\n<li><strong>Dynamic \/ Private \/ Ephemeral Ports (<code>49152\u201365535<\/code>):<\/strong> Unassigned client-side source ports allocated temporarily by the OS network stack when initiating an outbound connection and recycled once the session closes. Note that many Linux distributions expand local ephemeral allocation to <code>32768\u201360999<\/code> via <code>\/proc\/sys\/net\/ipv4\/ip_local_port_range<\/code>.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_difference_between_TCP_and_UDP_port_numbers\"><\/span>What is the difference between TCP and UDP port numbers?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>TCP and User Datagram Protocol (UDP) maintain completely separate 16-bit port namespaces. A service listening on TCP port <code>53<\/code> does not conflict with another socket bound to UDP port <code>53<\/code> on the same IP address. Because TCP is connection-oriented and establishes sessions through a three-way handshake (<code>SYN<\/code>, <code>SYN-ACK<\/code>, <code>ACK<\/code>), active TCP ports always report explicit lifecycle states such as <code>LISTEN<\/code>, <code>ESTABLISHED<\/code>, <code>CLOSE_WAIT<\/code>, or <code>TIME_WAIT<\/code>. UDP ports are connectionless and stateless, meaning they hold no handshake state to query.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_are_the_most_common_default_TCP_port_numbers\"><\/span>What are the most common default TCP port numbers?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Most standard network infrastructure services bind to predictable default TCP ports unless manually reconfigured:<\/p>\n<ul>\n<li><strong>20 \/ 21:<\/strong> FTP (Data transfer \/ Control command channel)<\/li>\n<li><strong>22:<\/strong> SSH, SCP, and SFTP<\/li>\n<li><strong>25 \/ 587:<\/strong> SMTP (Mail relay \/ Authenticated client mail submission)<\/li>\n<li><strong>53:<\/strong> DNS (Zone transfers and responses exceeding UDP payload limits)<\/li>\n<li><strong>80 \/ 443:<\/strong> HTTP \/ HTTPS<\/li>\n<li><strong>110 \/ 995:<\/strong> POP3 \/ POP3 over TLS<\/li>\n<li><strong>143 \/ 993:<\/strong> IMAP \/ IMAP over TLS<\/li>\n<li><strong>445:<\/strong> SMB (Windows file sharing and Active Directory)<\/li>\n<li><strong>1433:<\/strong> Microsoft SQL Server<\/li>\n<li><strong>3306:<\/strong> MySQL and MariaDB<\/li>\n<li><strong>3389:<\/strong> Windows Remote Desktop Protocol (RDP)<\/li>\n<li><strong>5432:<\/strong> PostgreSQL<\/li>\n<li><strong>8080 \/ 8443:<\/strong> Alternate HTTP proxies and web management interfaces<\/li>\n<\/ul>\n<p>When you encounter a port outside these familiar defaults and need to verify which protocol officially owns it, consult the canonical global port database detailed next.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Authoritative_Port_Lookup_The_IANA_Service_Name_and_Port_Number_Registry\"><\/span>Authoritative Port Lookup: The IANA Service Name and Port Number Registry<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <strong>Service Name and Transport Protocol Port Number Registry<\/strong>, maintained by the <strong>Internet Assigned Numbers Authority (IANA)<\/strong> pursuant to <strong>RFC 6335<\/strong>, is the official global database mapping transport-layer port numbers (<code>0\u201365535<\/code>) to registered protocol service names.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Official_Registry_Endpoints_and_Local_Mirrors\"><\/span>Official Registry Endpoints and Local Mirrors<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>Web Lookup Interface:<\/strong> <code>https:\/\/www.iana.org\/assignments\/service-names-port-numbers\/service-names-port-numbers.xhtml<\/code><\/li>\n<li><strong>Downloadable Machine-Readable Datasets:<\/strong> Available in <code>.csv<\/code>, <code>.xml<\/code>, and plain-text formats under <code>https:\/\/www.iana.org\/assignments\/service-names-port-numbers\/<\/code> (for example, <code>service-names-port-numbers.csv<\/code>).<\/li>\n<li><strong>Local Operating System Reference Files:<\/strong> Operating systems ship a static subset of the IANA registry for local port-to-name resolution at <code>\/etc\/services<\/code> on Linux, BSD, and macOS, and at <code>C:\\Windows\\System32\\drivers\\etc\\services<\/code> on Windows.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Registry_Record_Schema\"><\/span>Registry Record Schema<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Each authoritative entry in the IANA database exposes the following standardized fields:<\/p>\n<ul>\n<li><strong>Service Name:<\/strong> The unique identifier string used by applications and DNS SRV records (for example, <code>https<\/code> or <code>postgresql<\/code>).<\/li>\n<li><strong>Port Number:<\/strong> The assigned numeric value within the System (<code>0\u20131023<\/code>) or User (<code>1024\u201349151<\/code>) tiers.<\/li>\n<li><strong>Transport Protocol:<\/strong> The bound transport layer (<code>tcp<\/code>, <code>udp<\/code>, <code>sctp<\/code>, or <code>dccp<\/code>).<\/li>\n<li><strong>Description &amp; Reference:<\/strong> Concise protocol summary alongside the governing RFC or specification document.<\/li>\n<li><strong>Assignee, Contact, &amp; Dates:<\/strong> The organization or engineering body holding the registration, along with initial registration and modification dates.<\/li>\n<li><strong>Known Unauthorized Uses &amp; Assignment Notes:<\/strong> Documented port collisions, deprecated aliases, or security advisories associated with the port.<\/li>\n<\/ul>\n<p><strong>Operational Scope Note:<\/strong> An IANA entry reflects formal protocol assignment rather than mandatory runtime enforcement. Any local or remote application can be configured to listen on an arbitrary TCP port, so confirming actual runtime bindings requires querying the host directly\u2014starting with local Windows tools.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Find_Active_and_Listening_TCP_Ports_in_Windows\"><\/span>How to Find Active and Listening TCP Ports in Windows<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>On a Windows workstation or server, you can map open TCP ports directly to their owning executables using three built-in utilities without installing third-party software.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Method_1_Command_Prompt_netstat_and_tasklist\"><\/span>Method 1: Command Prompt (<code>netstat<\/code> and <code>tasklist<\/code>)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li>Open <strong>Command Prompt<\/strong> as Administrator (<code>Win + X<\/code> &gt; <strong>Terminal (Admin)<\/strong> or search <code>cmd<\/code> and select <strong>Run as administrator<\/strong>).<\/li>\n<li>List all active and listening IPv4 and IPv6 TCP endpoints numerically along with their Process IDs (<code>PID<\/code>):<br \/>\n   <code>cmd<br \/>\n   netstat -ano | findstr \"TCP\"<\/code><\/li>\n<li><code>-a<\/code> displays both active connections and listening server ports.<\/li>\n<li><code>-n<\/code> prints IP addresses and port numbers numerically instead of resolving hostnames or <code>\/etc\/services<\/code> labels.<\/li>\n<li><code>-o<\/code> appends the owning <code>PID<\/code> in the rightmost column.<br \/>\n   To isolate only bound server ports waiting for inbound traffic, filter by state:<br \/>\n   <code>cmd<br \/>\n   netstat -ano | findstr \"LISTENING\"<\/code><\/li>\n<li>Match the <code>PID<\/code> from the output (for example, <code>4120<\/code>) to its running application binary:<br \/>\n   <code>cmd<br \/>\n   tasklist \/fi \"pid eq 4120\"<\/code><br \/>\n   Alternatively, run <code>netstat -abno<\/code> in an elevated prompt to print the executable name directly beneath each socket entry.<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Method_2_PowerShell_Get-NetTCPConnection\"><\/span>Method 2: PowerShell (<code>Get-NetTCPConnection<\/code>)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li>Launch an elevated <strong>PowerShell<\/strong> window.<\/li>\n<li>Query bound TCP listeners and join each <code>OwningProcess<\/code> ID to <code>Get-Process<\/code> in a single pipeline:<br \/>\n   <code>powershell<br \/>\n   Get-NetTCPConnection -State Listen |<br \/>\n     Select-Object LocalAddress, LocalPort, State, OwningProcess,<br \/>\n       @{Name=\"ProcessName\";Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName}} |<br \/>\n     Sort-Object LocalPort |<br \/>\n     Format-Table -AutoSize<\/code><\/li>\n<li>To inspect a single TCP port (such as port <code>443<\/code>) across all connection states (<code>Listen<\/code>, <code>Established<\/code>, <code>TimeWait<\/code>), filter with <code>-LocalPort<\/code>:<br \/>\n   <code>powershell<br \/>\n   Get-NetTCPConnection -LocalPort 443<\/code><\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Method_3_Windows_Resource_Monitor_GUI\"><\/span>Method 3: Windows Resource Monitor (GUI)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li>Press <code>Win + R<\/code>, type <code>resmon.exe<\/code>, and press <strong>Enter<\/strong>.<\/li>\n<li>Select the <strong>Network<\/strong> tab.<\/li>\n<li>Expand <strong>Listening Ports<\/strong> to view every bound TCP port alongside its <strong>Image<\/strong> (executable name), <strong>PID<\/strong>, bound <strong>Address<\/strong>, and <strong>Firewall Status<\/strong> (such as <em>Allowed, not restricted<\/em>). Expand <strong>TCP Connections<\/strong> directly above it to inspect live local-to-remote port pairs in real time.<\/li>\n<\/ol>\n<p>If you are auditing a Linux server or container environment instead of a Windows host, equivalent socket-to-daemon mapping is handled from the terminal.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Audit_Listening_TCP_Ports_and_Daemons_in_Linux\"><\/span>How to Audit Listening TCP Ports and Daemons in Linux<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Modern Linux distributions provide direct kernel socket inspection through <code>iproute2<\/code> (<code>ss<\/code>) and file-descriptor utilities (<code>lsof<\/code>). Always prefix these commands with <code>sudo<\/code>; without root privileges, Linux hides PID and daemon names for sockets owned by <code>root<\/code> or other system accounts.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_1_Audit_Listening_TCP_Sockets_with_ss\"><\/span>Step 1: Audit Listening TCP Sockets with <code>ss<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><code>ss<\/code> queries kernel <code>tcp_diag<\/code> structures directly, making it faster and more detailed than older procfs parsers:<\/p>\n<pre><code class=\"language-bash\">sudo ss -tlnp\n<\/code><\/pre>\n<ul>\n<li><code>-t<\/code>: Restricts output to TCP sockets.<\/li>\n<li><code>-l<\/code>: Shows only sockets in the <code>LISTEN<\/code> state (replace <code>-l<\/code> with <code>-a<\/code> to include <code>ESTAB<\/code> and <code>TIME-WAIT<\/code> sessions).<\/li>\n<li><code>-n<\/code>: Forces numeric port output, bypassing <code>\/etc\/services<\/code> name translation referenced earlier.<\/li>\n<li><code>-p<\/code>: Prints the owning process name, <code>pid<\/code>, and socket file descriptor.<\/li>\n<\/ul>\n<p>Inspect the <code>Local Address:Port<\/code> column carefully: <code>0.0.0.0:8080<\/code> or <code>[::]:8080<\/code> means the port accepts external connections across interfaces, whereas <code>127.0.0.1:8080<\/code> restricts access strictly to local loopback processes.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_Find_TCP_Ports_by_Process_ID_or_Port_Number_with_lsof\"><\/span>Step 2: Find TCP Ports by Process ID or Port Number with <code>lsof<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Because Unix treats network sockets as open files, <code>lsof<\/code> excels at targeted lookups when you already know a daemon&#8217;s PID or suspect a specific port collision:<\/p>\n<ul>\n<li><strong>List all listening TCP sockets system-wide:<\/strong><br \/>\n  <code>bash<br \/>\n  sudo lsof -nP -iTCP -sTCP:LISTEN<\/code><\/li>\n<li><strong>Find every TCP port bound or connected by a specific PID (for example, PID <code>1842<\/code>):<\/strong><br \/>\n  <code>bash<br \/>\n  sudo lsof -Pan -p 1842 -iTCP<\/code><br \/>\n  Always include <code>-a<\/code> (logical AND); omitting <code>-a<\/code> causes <code>lsof<\/code> to return all open files for PID <code>1842<\/code> plus every TCP socket across the entire system.<\/li>\n<li><strong>Identify which daemon holds a specific TCP port (for example, <code>3306<\/code>):<\/strong><br \/>\n  <code>bash<br \/>\n  sudo lsof -nP -iTCP:3306<\/code><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_Fallback_Check_with_Legacy_netstat\"><\/span>Step 3: Fallback Check with Legacy <code>netstat<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>On legacy servers or minimal appliances where <code>net-tools<\/code> is installed instead of <code>lsof<\/code>, run the equivalent flag combination:<\/p>\n<pre><code class=\"language-bash\">sudo netstat -tlnp\n<\/code><\/pre>\n<p>Local terminal commands require shell access to the host. When you need to discover open TCP ports on an external server, router, or network printer over the network, you must switch to active port probing.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Scan_and_Discover_Open_TCP_Ports_on_a_Remote_IP_Address\"><\/span>How to Scan and Discover Open TCP Ports on a Remote IP Address<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Active port discovery sends TCP handshake probes over the network to determine which ports on a remote IP are accepting connections. Only scan external hosts or subnets that you own or have explicit authorization to test.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_1_Test_a_Single_Known_Remote_TCP_Port\"><\/span>Step 1: Test a Single Known Remote TCP Port<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>When verifying firewall reachability to a known service endpoint, use built-in single-port connection testers:<\/p>\n<ul>\n<li><strong>From Windows PowerShell:<\/strong><br \/>\n  <code>powershell<br \/>\n  Test-NetConnection -ComputerName 192.168.1.50 -Port 443<\/code><br \/>\n  Check the <code>TcpTestSucceeded<\/code> boolean (<code>True<\/code> confirms a completed TCP three-way handshake).<\/li>\n<li><strong>From Linux or macOS (<code>nc<\/code> \/ Netcat):<\/strong><br \/>\n  <code>bash<br \/>\n  nc -zv -w 3 192.168.1.50 443<\/code><br \/>\n  <code>-z<\/code> performs a zero-I\/O handshake check without sending application data, <code>-v<\/code> prints verbose status, and <code>-w 3<\/code> enforces a 3-second timeout.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_Scan_Common_Server_Ports_with_Nmap\"><\/span>Step 2: Scan Common Server Ports with Nmap<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>When you do not know which TCP ports a remote server exposes, use <strong>Nmap<\/strong> to sweep the top 1,000 most commonly used TCP ports:<\/p>\n<pre><code class=\"language-bash\">sudo nmap -sS 192.168.1.50\n<\/code><\/pre>\n<p>Running <code>-sS<\/code> with elevated privileges executes a half-open <code>SYN<\/code> scan, whereas unprivileged users can run <code>nmap -sT 192.168.1.50<\/code> for a full OS <code>connect()<\/code> scan. Nmap classifies probed ports into three primary states:<br \/>\n&#8211; <strong><code>open<\/code>:<\/strong> Target port replied with <code>SYN-ACK<\/code>; an application is actively listening.<br \/>\n&#8211; <strong><code>closed<\/code>:<\/strong> Target host is reachable and replied with <code>RST<\/code>; no process is bound to that port.<br \/>\n&#8211; <strong><code>filtered<\/code>:<\/strong> A firewall or packet filter silently dropped the probe or returned an ICMP administrative prohibition, preventing confirmation.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_Discover_Hardware_and_Non-Standard_Ports_Printers_Routers_Appliances\"><\/span>Step 3: Discover Hardware and Non-Standard Ports (Printers, Routers, Appliances)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Network printers, managed switches, and routers frequently expose administration portals or print queues outside Nmap&#8217;s default 1,000-port list\u2014or run web interfaces on custom high ports (<code>8080<\/code>, <code>8443<\/code>, <code>9100<\/code> for JetDirect\/RAW printing, <code>631<\/code> for IPP, or <code>515<\/code> for LPD). To scan all 65,535 TCP ports and fingerprint the exact daemon behind each open port, run:<\/p>\n<pre><code class=\"language-bash\">sudo nmap -sS -sV -p- -T4 192.168.1.50\n<\/code><\/pre>\n<p><code>-p-<\/code> instructs Nmap to sweep ports <code>1<\/code> through <code>65535<\/code>, and <code>-sV<\/code> interrogates open ports to identify the underlying firmware, HTTP server, or print service banner.<\/p>\n<p>Some network workflows still evade both local socket polling and inbound port scans\u2014specifically ultra-brief outbound client connections or locked-down IoT devices that ignore inbound probes. In those cases, passive packet capture reveals the exact TCP port numbers directly from wire headers.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Capturing_Short-Lived_or_Unknown_TCP_Ports_with_Wireshark_and_tcpdump\"><\/span>Capturing Short-Lived or Unknown TCP Ports with Wireshark and tcpdump<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Inspecting live packet headers captures every TCP connection attempt at the wire level, even if a process opens a socket for only a few milliseconds before terminating.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_1_Start_a_Scoped_Capture_in_Wireshark\"><\/span>Step 1: Start a Scoped Capture in Wireshark<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li>Open <strong>Wireshark<\/strong> with administrative or <code>wireshark<\/code>-group capture permissions.<\/li>\n<li>Double-click the active network interface carrying the traffic (or a switch SPAN\/mirror port if monitoring an external hardware appliance).<\/li>\n<li>Reproduce the application login, sync action, or device boot sequence you want to analyze.<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_Apply_Wireshark_Display_Filters_to_Isolate_TCP_Ports\"><\/span>Step 2: Apply Wireshark Display Filters to Isolate TCP Ports<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Type the following expressions into the top <strong>Display Filter<\/strong> bar and press <strong>Enter<\/strong> to strip away background noise:<\/p>\n<ul>\n<li><strong>Show all TCP packets involving a target device IP:<\/strong><br \/>\n  <code>text<br \/>\n  ip.addr == 192.168.1.120 &amp;&amp; tcp<\/code><\/li>\n<li><strong>Show only initial outbound <code>SYN<\/code> connection requests:<\/strong><br \/>\n  <code>text<br \/>\n  tcp.flags.syn == 1 &amp;&amp; tcp.flags.ack == 0<\/code><br \/>\n  This filter is the fastest way to find an unknown server port: because clients originate connections from random ephemeral ports (as covered in the port ranges FAQ above), the <strong>Destination Port<\/strong> of an initial <code>SYN<\/code> packet always reveals the exact listening service port the client is trying to reach.<\/li>\n<li><strong>Verify bidirectional traffic on a specific TCP port:<\/strong><br \/>\n  <code>text<br \/>\n  tcp.port == 8443<\/code><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_Read_Header_Fields_and_Conversation_Summaries\"><\/span>Step 3: Read Header Fields and Conversation Summaries<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Click any captured packet and expand <strong>Transmission Control Protocol<\/strong> in the middle <strong>Packet Details<\/strong> pane to inspect <code>Source Port<\/code> and <code>Destination Port<\/code>. To compile a clean inventory of every TCP port used across the entire capture without clicking individual packets, navigate to <strong>Statistics &gt; Conversations<\/strong> and open the <strong>TCP<\/strong> tab to sort all endpoints by <strong>Port A<\/strong> and <strong>Port B<\/strong>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_4_Inspect_TCP_Ports_on_Headless_Hosts_with_tcpdump\"><\/span>Step 4: Inspect TCP Ports on Headless Hosts with <code>tcpdump<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>On remote Linux servers or firewall appliances without a desktop GUI, capture raw numeric TCP headers directly in the terminal:<\/p>\n<pre><code class=\"language-bash\">sudo tcpdump -nn -i eth0 'tcp and host 192.168.1.120'\n<\/code><\/pre>\n<p>The <code>-nn<\/code> flag disables both DNS hostname lookups and service-name translation, printing exact <code>SourceIP.SourcePort &gt; DestIP.DestPort<\/code> pairs in real time.<\/p>\n<p>While CLI tools and packet analyzers handle deep diagnostics, dedicated GUI socket monitors and high-speed scanners streamline day-to-day visual inspection and subnet discovery.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Comparing_Dedicated_TCP_Port_Scanners_and_GUI_Socket_Viewers\"><\/span>Comparing Dedicated TCP Port Scanners and GUI Socket Viewers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Network port utilities fall into two distinct categories: <strong>local GUI socket viewers<\/strong> that monitor live process-to-port activity on your workstation, and <strong>remote network scanners<\/strong> that sweep external hosts and subnets.<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Tool<\/th>\n<th style=\"text-align: left;\">Discovery Scope<\/th>\n<th style=\"text-align: left;\">Supported OS<\/th>\n<th style=\"text-align: left;\">Interface<\/th>\n<th style=\"text-align: left;\">Standout Capabilities<\/th>\n<th style=\"text-align: left;\">Primary Limitation<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>Nmap (with Zenmap)<\/strong><\/td>\n<td style=\"text-align: left;\">Remote networks &amp; local host<\/td>\n<td style=\"text-align: left;\">Windows, Linux, macOS<\/td>\n<td style=\"text-align: left;\">CLI + Zenmap GUI<\/td>\n<td style=\"text-align: left;\">Industry-standard <code>SYN<\/code> stealth scans, <code>-sV<\/code> service\/banner detection, OS fingerprinting, and NSE automation scripts<\/td>\n<td style=\"text-align: left;\">Steeper CLI learning curve; raw packet scans require root\/Administrator and Npcap on Windows<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Sysinternals TCPView<\/strong><\/td>\n<td style=\"text-align: left;\">Local host sockets only<\/td>\n<td style=\"text-align: left;\">Windows<\/td>\n<td style=\"text-align: left;\">GUI + <code>tcpvcon<\/code> CLI<\/td>\n<td style=\"text-align: left;\">Real-time color-coded view of opening (green) and closing (red) sockets, instant PID\/process mapping, and one-click connection termination<\/td>\n<td style=\"text-align: left;\">Cannot probe remote IP addresses across a network<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Angry IP Scanner<\/strong><\/td>\n<td style=\"text-align: left;\">Remote IP ranges &amp; subnets<\/td>\n<td style=\"text-align: left;\">Windows, Linux, macOS<\/td>\n<td style=\"text-align: left;\">GUI<\/td>\n<td style=\"text-align: left;\">Fast multi-threaded subnet sweeps with customizable TCP port lists and one-click CSV, TXT, or XML export<\/td>\n<td style=\"text-align: left;\">Requires a local Java runtime (JRE) and lacks deep protocol banner fingerprinting<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>NirSoft CurrPorts<\/strong><\/td>\n<td style=\"text-align: left;\">Local host sockets only<\/td>\n<td style=\"text-align: left;\">Windows<\/td>\n<td style=\"text-align: left;\">Portable GUI<\/td>\n<td style=\"text-align: left;\">Standalone zero-install executable, custom port\/process filter rules, and automated background logging of socket changes<\/td>\n<td style=\"text-align: left;\">Windows-only and restricted strictly to local machine endpoints<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>RustScan<\/strong><\/td>\n<td style=\"text-align: left;\">Remote hosts &amp; large port ranges<\/td>\n<td style=\"text-align: left;\">Windows, Linux, macOS, Docker<\/td>\n<td style=\"text-align: left;\">CLI<\/td>\n<td style=\"text-align: left;\">Asynchronous engine capable of sweeping all 65,535 TCP ports in seconds and piping open ports directly into Nmap<\/td>\n<td style=\"text-align: left;\">CLI-only; aggressive default concurrency can trigger IDS alerts or firewall rate-limiting<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Choose <strong>TCPView<\/strong> or <strong>CurrPorts<\/strong> when troubleshooting which local Windows background process is binding or cycling TCP ports in real time; choose <strong>Angry IP Scanner<\/strong> for quick visual LAN audits, and pair <strong>RustScan<\/strong> or <strong>Nmap<\/strong> when comprehensive remote 65,535-port coverage and service identification are required. When you need scheduled, dependency-free port verification across dozens of enterprise servers without installing third-party binaries, lightweight script templates provide repeatable CSV reporting.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ready-to-Use_PowerShell_and_Python_TCP_Port_Audit_Scripts\"><\/span>Ready-to-Use PowerShell and Python TCP Port Audit Scripts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Replace the host lists, TCP port arrays, and timeout values in either template below to run an automated multi-host TCP port sweep and generate a timestamped <code>tcp_port_audit.csv<\/code> report.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"PowerShell_Multi-Host_TCP_Port_Scanner_Invoke-TcpPortAuditps1\"><\/span>PowerShell Multi-Host TCP Port Scanner (<code>Invoke-TcpPortAudit.ps1<\/code>)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Uses asynchronous <code>.NET<\/code> <code>TcpClient<\/code> sockets to avoid <code>Test-NetConnection<\/code>&#8216;s multi-second timeout delays on closed ports:<\/p>\n<pre><code class=\"language-powershell\"># Customize target hosts, TCP ports, per-port timeout (ms), and output path\n$TargetHosts = @(&quot;192.168.1.10&quot;, &quot;192.168.1.20&quot;, &quot;db01.corp.example.com&quot;)\n$TargetPorts = @(22, 80, 443, 1433, 3389, 5432, 8080)\n$TimeoutMs   = 500\n$OutputCsv   = &quot;.\\tcp_port_audit.csv&quot;\n\n$AuditResults = foreach ($HostName in $TargetHosts) {\n    foreach ($Port in $TargetPorts) {\n        $Client = New-Object System.Net.Sockets.TcpClient\n        try {\n            $ConnectTask = $Client.ConnectAsync($HostName, $Port)\n            $IsOpen = $ConnectTask.Wait($TimeoutMs) -and $Client.Connected\n        } catch {\n            $IsOpen = $false\n        } finally {\n            $Client.Dispose()\n        }\n\n        [PSCustomObject]@{\n            Timestamp  = (Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ssZ&quot;)\n            TargetHost = $HostName\n            TcpPort    = $Port\n            Status     = if ($IsOpen) { &quot;Open&quot; } else { &quot;ClosedOrFiltered&quot; }\n        }\n    }\n}\n\n$AuditResults | Export-Csv -Path $OutputCsv -NoTypeInformation\n$AuditResults | Where-Object Status -eq &quot;Open&quot; | Format-Table -AutoSize\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Cross-Platform_Python_3_Concurrent_TCP_Port_Scanner_tcp_port_auditpy\"><\/span>Cross-Platform Python 3 Concurrent TCP Port Scanner (<code>tcp_port_audit.py<\/code>)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Uses only the Python 3 standard library (<code>socket<\/code>, <code>concurrent.futures<\/code>, <code>csv<\/code>) with IPv4\/IPv6 support:<\/p>\n<pre><code class=\"language-python\">#!\/usr\/bin\/env python3\nimport csv\nimport socket\nfrom concurrent.futures import ThreadPoolExecutor, as_completed\nfrom datetime import datetime, timezone\n\n# Customize target hosts, TCP ports, timeout (seconds), concurrency, and CSV path\nTARGET_HOSTS = [&quot;192.168.1.10&quot;, &quot;192.168.1.20&quot;, &quot;db01.corp.example.com&quot;]\nTARGET_PORTS = [22, 80, 443, 1433, 3389, 5432, 8080]\nTIMEOUT_SEC = 0.5\nMAX_WORKERS = 50\nOUTPUT_CSV = &quot;tcp_port_audit.csv&quot;\n\n\ndef check_tcp_port(host: str, port: int) -&gt; dict:\n    status = &quot;ClosedOrFiltered&quot;\n    try:\n        with socket.create_connection((host, port), timeout=TIMEOUT_SEC):\n            status = &quot;Open&quot;\n    except OSError:\n        pass\n    return {\n        &quot;timestamp&quot;: datetime.now(timezone.utc).strftime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;),\n        &quot;target_host&quot;: host,\n        &quot;tcp_port&quot;: port,\n        &quot;status&quot;: status,\n    }\n\n\ndef main() -&gt; None:\n    targets = [(h, p) for h in TARGET_HOSTS for p in TARGET_PORTS]\n    results = []\n    with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:\n        futures = [executor.submit(check_tcp_port, h, p) for h, p in targets]\n        for future in as_completed(futures):\n            results.append(future.result())\n\n    results.sort(key=lambda r: (r[&quot;target_host&quot;], r[&quot;tcp_port&quot;]))\n    with open(OUTPUT_CSV, mode=&quot;w&quot;, newline=&quot;&quot;, encoding=&quot;utf-8&quot;) as csv_file:\n        writer = csv.DictWriter(\n            csv_file, fieldnames=[&quot;timestamp&quot;, &quot;target_host&quot;, &quot;tcp_port&quot;, &quot;status&quot;]\n        )\n        writer.writeheader()\n        writer.writerows(results)\n\n\nif __name__ == &quot;__main__&quot;:\n    main()\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Finding a TCP port number comes down to matching your inspection method to your vantage point on the network. Reference the IANA registry when verifying standard protocol assignments, run <code>Get-NetTCPConnection<\/code>, <code>netstat<\/code>, <code>ss<\/code>, or <code>lsof<\/code> when mapping local sockets directly to host PIDs, and turn to <code>nmap<\/code> when discovering exposed services across remote servers or network hardware. When short-lived client sessions or undocumented appliances hide their activity from polling tools, packet captures in Wireshark or <code>tcpdump<\/code> expose the exact source and destination ports on the wire, while GUI monitors and scripted CSV sweeps keep ongoing port visibility repeatable across larger environments.<\/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-find-tcp-port-number_25453.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+Find+TCP+Port+Number+https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.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-find-tcp-port-number_25453.html\",\"How to Find TCP Port Number\")' 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>Locating the exact TCP port number behind a network service or active connection is a routine necessity when troubleshooting port binding conflicts, writing firewall rules, auditing server exposure, or integrating unfamiliar hardware onto a LAN. Depending on whether you have local shell access, are probing a remote IP across the network, or need to catch&#8230; &raquo; <a class=\"read-more-link\" href=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\">read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":25452,"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 Find TCP Port Number - 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-find-tcp-port-number_25453.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Find TCP Port Number - SPOTO Official Blog\" \/>\n<meta property=\"og:description\" content=\"Locating the exact TCP port number behind a network service or active connection is a routine necessity when troubleshooting port binding conflicts, writing firewall rules, auditing server exposure, or integrating unfamiliar hardware onto a LAN. Depending on whether you have local shell access, are probing a remote IP across the network, or need to catch... &raquo; read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\" \/>\n<meta property=\"og:site_name\" content=\"SPOTO Official Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-12-03T14:03:13+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-find-tcp-port-number_25453.html#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-find-tcp-port-number.png\",\"contentUrl\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-find-tcp-port-number.png\",\"width\":1024,\"height\":768,\"caption\":\"How to Find TCP Port Number\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#webpage\",\"url\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\",\"name\":\"How to Find TCP Port Number - SPOTO Official Blog\",\"isPartOf\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#primaryimage\"},\"datePublished\":\"2026-12-03T14:03:13+00:00\",\"dateModified\":\"2026-12-03T14:03:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cciedump.spoto.net\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Find TCP Port Number\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#webpage\"},\"author\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/4edd6074d9632c14eda17a2205a88dd1\"},\"headline\":\"How to Find TCP Port Number\",\"datePublished\":\"2026-12-03T14:03:13+00:00\",\"dateModified\":\"2026-12-03T14:03:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#webpage\"},\"wordCount\":2389,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638\"},\"image\":{\"@id\":\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-find-tcp-port-number.png\",\"articleSection\":[\"Routing &amp; Switching\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.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 Find TCP Port Number - 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-find-tcp-port-number_25453.html","og_locale":"en_US","og_type":"article","og_title":"How to Find TCP Port Number - SPOTO Official Blog","og_description":"Locating the exact TCP port number behind a network service or active connection is a routine necessity when troubleshooting port binding conflicts, writing firewall rules, auditing server exposure, or integrating unfamiliar hardware onto a LAN. Depending on whether you have local shell access, are probing a remote IP across the network, or need to catch... &raquo; read more","og_url":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html","og_site_name":"SPOTO Official Blog","article_published_time":"2026-12-03T14:03:13+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-find-tcp-port-number_25453.html#primaryimage","inLanguage":"en-US","url":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-find-tcp-port-number.png","contentUrl":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-find-tcp-port-number.png","width":1024,"height":768,"caption":"How to Find TCP Port Number"},{"@type":"WebPage","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#webpage","url":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html","name":"How to Find TCP Port Number - SPOTO Official Blog","isPartOf":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#primaryimage"},"datePublished":"2026-12-03T14:03:13+00:00","dateModified":"2026-12-03T14:03:13+00:00","breadcrumb":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cciedump.spoto.net\/blog"},{"@type":"ListItem","position":2,"name":"How to Find TCP Port Number"}]},{"@type":"Article","@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#article","isPartOf":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#webpage"},"author":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/4edd6074d9632c14eda17a2205a88dd1"},"headline":"How to Find TCP Port Number","datePublished":"2026-12-03T14:03:13+00:00","dateModified":"2026-12-03T14:03:13+00:00","mainEntityOfPage":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#webpage"},"wordCount":2389,"commentCount":0,"publisher":{"@id":"https:\/\/cciedump.spoto.net\/blog\/#\/schema\/person\/25594d4796697ccb1ef63d55c269c638"},"image":{"@id":"https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.html#primaryimage"},"thumbnailUrl":"https:\/\/cciedump.spoto.net\/blog\/wp-content\/uploads\/2026\/12\/how-to-find-tcp-port-number.png","articleSection":["Routing &amp; Switching"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cciedump.spoto.net\/blog\/how-to-find-tcp-port-number_25453.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\/25453"}],"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=25453"}],"version-history":[{"count":0,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/posts\/25453\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/media\/25452"}],"wp:attachment":[{"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/media?parent=25453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/categories?post=25453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cciedump.spoto.net\/blog\/wp-json\/wp\/v2\/tags?post=25453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}