CMD Netstat Command in Depth: Options, Examples, and Security

Last update: 14/08/2025
Author Isaac
  • Full visibility into connections: states, ports, and PIDs for diagnostics and security.
  • Statistics and routes: counters per protocol, interfaces and routing table.
  • Conflict detection: filtering with findstr and cases such as ArcGIS Server.

Netstat command in CMD

If you've ever wondered what connections your PC is opening, what ports are in use, or why your network is stuttering, the netstat command is your direct ally from the symbol of the system. This line utility commands It has existed since the 90s in Unix and also at Microsoft Windows, and provides a very valuable snapshot of what is happening at the level of sockets, routing tables, and network statistics.

Although netstat doesn't have a graphical interface and can be complex at first, with a few well-chosen options it can quickly detect intrusions, port conflicts, bottlenecks, suspicious processes, and network layer errors. In addition, being integrated into both Windows and Linux and macOS, it is a universal tool that does not require installing anything.

What is netstat and why it deserves a place in your toolbox?

Netstat stands for Network Statistics and, as its name suggests, displays statistics and statuses related to your connections and protocols. You can see open (listening) ports, established and closed connections, local and remote addresses, and even the process ID (PID) behind each socket in Windows.

Its practical utility is enormous for administration and security: discover services that should not be active, identify malware wait for a port to open, analyze routes and routing metrics, or review error counters that indicate physical or logical failures in the network.

The tool is present in Windows, Linux, Unix and macOS, and although in modern environments part of its use has shifted towards PowerShell or specific utilities, it remains a fast and ubiquitous command that resolves doubts in seconds. If you prefer visuals, you can rely on alternatives like TCPView in Windows to represent the same information graphically.

Starting tip for clean measurements: Close applications that generate traffic and, if possible, restart your computer and open only the essential applications before running Netstat to avoid data noise and facilitate analysis.

Impact on performance and best practices for use

Running netstat occasionally does not degrade system performance, but excessive refreshes and verbose output can increase CPU and memory usage, especially with thousands of connections. The cost comes from enumerating sockets, resolving names, and gathering statistics.

Recommendations to minimize impact: Limit use to diagnostic times, filter with specific parameters (for example, -n to not resolve names, -p for a protocol), avoid very fast execution loops, and consider specialized tools if you need more granular continuous monitoring.

  How To Discover if Someone Has Blocked You on Facebook

In corporate environments, it is advisable that the execution of netstat is documented and performed after assessing the need, as There Investing in indiscriminate inspections can translate into operating costs with no clear return.

How to use netstat in Windows (CMD and Terminal)

netstat windows

On Windows you can open netstat from DCM or from the Bus Terminal (Windows 10/11) with administrator permissions to see all available information, including PID and full name resolution where necessary.

Start by typing netstat and press Enter to see a snapshot of active connections, where columns such as Proto (TCP/UDP), Local Address, Remote Address and Status (LISTENING, ESTABLISHED, TIME_WAIT, CLOSE_WAIT, etc.) are listed.

General syntax

The canonical form on Windows follows this pattern: netstat . You can combine parameters; if you include an interval in seconds, the output is refreshed every X seconds.

Useful notes: -n shows everything in numeric format (faster by avoiding DNS), -o adds the PID, -p filters by protocol (TCP, UDP, TCPv6 or UDPv6) and -f shows fully qualified domain names (FQDNs) when possible.

How to read the output

The Status column is key: LISTENING indicates open ports waiting for connections; ESTABLISHED indicates active connections; TIME_WAIT and CLOSE_WAIT reflect closing phases in TCP; there are no states in UDP because it is connectionless.

The Local Address shows the IP:port of the computer and the Foreign Address, the remote end, which with -f can include FQDNs to facilitate tracking. With -n you'll always see numbers (faster and less ambiguous).

Common netstat parameters and options

-to: Lists all listening connections and ports, useful for discovering active services and sockets waiting for clients.

-and: Interface statistics (bytes, packets, discards, errors). This is a quick look at traffic and possible RX/TX anomalies.

-F: Attempts to display the fully qualified domain name (FQDN) for remote addresses, very handy when investigating unknown destinations.

on: Unresolved DNS numeric output; speeds up execution and avoids diagnostic confusion.

-either: adds the PID of the process associated with each connection in Windows, the piece you need to cross with the Task Manager or tasklist.

-p Protocol: Filter by TCP, UDP, TCPv6, or UDPv6. On Windows, the protocol name is used (e.g., netstat -p TCP), no "IP".

-q: displays bound listening and non-listening ports, useful for reviewing socket associations.

-s: Statistics grouped by protocol (IPv4, IPv6, TCP, UDP, ICMP), with packet, error and retransmission counters.

-r: exposes the routing table and list of interfaces, essential for validating the default gateway and active routes.

-t: displays timer/download information on connections (support and semantics may vary by system).

-x: Details NetworkDirect connections when present, relevant in specific environments.

  What is Windows 365 Reserve and how does it ensure your continuity?

: Add periodic refresh, for example, netstat -n 7 to update every 7 seconds; use sparingly to avoid overloading the system.

Practical step-by-step examples

The best thing about netstat is that each switch answers a specific question that arises every day in networking and security. Here are uses ranging from the basics to the more detective-like.

Open ports and associated processes

To see at a glance what is listening, what connections exist, and what process is holding them, use netstat -ano, which combines numerical and PID output.

With the PID in hand, open Task Manager (Details tab) or use tasklist to identify the executable, and thus confirm whether it is a legitimate service or something suspicious.

Filter by state with findstr

If you only want established connections, you can chain with findstr: netstat | findstr ESTABLISHEDTo see listening sockets, change the term to LISTENING, and for closings, use CLOSE_WAIT or TIME_WAIT.

This quick filtering lets you focus on what matters without drowning in lines, especially useful on computers with many simultaneous browsers, clients, and services.

Just a protocol

To list only TCP on Windows, run: netstat -p TCP -anoIf you are interested in UDP, replace the protocol. This way you reduce noise and speed up the analysis.

In some guides you will see "-p IP" for IPv4, but on Windows the parameter expects TCP/UDP (or their v6 variants), while in Linux there are other switches for similar roles.

Statistics by protocol and interfaces

To detect losses, dropped packets, retransmissions or strange spikes, run netstat -s and check IPv4/IPv6, TCP, UDP and ICMP counters.

If you want to see statistics per interface (bytes, packets, errors), netstat -e It gives you a clear summary that helps evaluate traffic direction and link quality.

Routing Table and Remote FQDN

With netstat -r you check the default route, active routes and available interfaces, very useful if Internet access fails or internal routes do not arrive.

To research destinations, netstat -f will attempt to resolve the FQDN of the remote host; you can tune with view open ports in Windows or use netstat -f | findstr "amazonaws.com".

Security and Diagnostics: How to Detect Suspicious Behavior or Bottlenecks

Netstat -ano is used to hunt down strange connections and processes that you don't know about, cross-referencing the PID with the executable in Task Manager or with tools like TCPView. If you discover an unknown remote target, investigate it before taking action.

If you detect suspicious remote IPs, you can expand with netstat -aof to see FQDN and PID, and then block the suspicious IP address in Windows Firewall while running an antivirus/EDR. In serious cases, temporarily disconnect the computer from the network.

3 Best Tools to Detect Keyloggers in Windows 11
Related article:
3 Best Tools to Detect Keyloggers in Windows 11

To monitor in "almost" real time without external tools, uses netstat -n 5 to refresh every 5 seconds; remember that it's not intended as a continuous monitor, and if you need it, consider specialized solutions.

  How to change the language in Bitlife step by step

Bottlenecks can arise from the accumulation of connections in waiting states or from error counters in -s y -e, which points to congestion, wiring problems or driversIf you see a lot of “Retransmitted Segments” in TCP, keep an eye on latency and loss.

Checking for port conflicts: ArcGIS Server case

Before deploying services that require specific ports (such as ArcGIS Server), It is advisable to validate that these ports are free and not listening to other processes.

A handy command is to chain netstat with findstr to search for specific ports in LISTENING: netstat -ao | findstr "LISTENING" | findstr "4000 4001 4002 4003 6080 6443".

If any port appears busy, take note of the PID (right column), Go to Task Manager > Details and locate the process. If it belongs to ArcGIS itself (for example, javaw.exe with the service user), there is no conflict. If not, reconfigure the service or reassign the port.

Please note that a firewall, antivirus or perimeter security may block ports regardless of whether the local system has them free, so please also validate the network policies.

Other useful network commands in Windows

Netstat is not alone: combining it with other system commands multiplies its diagnostic value. Here are the essentials to wear on your head.

  • ipconfig: displays IP configuration, mask, gateway and allows DHCP renewal; base to know where you are coming from and where you are aiming.
  • ping: Checks range and latency to a host; useful for confirming connectivity and measuring round-trip times.
  • tracert: It exposes the hop route to a destination, which is key to locating where traffic is cut off or where delays increase.
  • pathping: combines ping and tracert with hop loss metrics, very useful although slower in execution.
  • getmac: reveals the address MAC, necessary for controls by filtering or inventorying hardware.
  • nslookup: Check DNS resolutions (domain <-> IP), essential if you see names that don't resolve or unexpected mappings.
  • netsh: the network shell to configure everything from Wi-Fi profiles to firewall rules, very powerful if you need to change stack or firewall parameters.
Shell commands: for use in the Windows 11 File Explorer address bar
Related article:
Shell and CMD commands for the address bar in Windows 11

Leave a comment