Skip to main content

Command referencenetstat

netstat command (Windows / CMD)

WindowsCMDnetworkbeginner

What it does

Display active connections, listening ports, routing data, and protocol statistics. Searches for the netstat command cmd windows usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.

Display active connections, listening ports, routing data, and protocol statistics.

Syntax

netstat [-a] [-b] [-e] [-n] [-o] [-p protocol] [interval]

Common options

Flag / optionMeaning
-aShow connections and listening ports.
-nKeep addresses and ports numeric.
-oInclude owning process IDs.
-bShow executables involved; elevation is usually required.
-rDisplay the routing table.

Practical examples

Ports and PIDs

netstat -ano

Lists numeric endpoints and owning PIDs.

Find a port

netstat -ano | findstr ":8080"

Filters rows involving port 8080.

Routing table

netstat -r

Shows IPv4 and IPv6 routes.

Linux ↔ Windows equivalent

Closest match: ss (Linux / bash / sh / zsh). Inspect network sockets, listeners, and connection statistics.

Common mistakes

  • Confusing a PID with an executable name; correlate it with tasklist.
  • Running `-b` without elevation and expecting complete output.

FAQ

What does netstat do in Command Prompt?

Display active connections, listening ports, routing data, and protocol statistics.

How do I run netstat in CMD?

Open Command Prompt and follow `netstat [-a] [-b] [-e] [-n] [-o] [-p protocol] [interval]`; quote paths containing spaces.

What is a practical netstat example in CMD?

Try `netstat -ano` — Lists numeric endpoints and owning PIDs.

Can netstat be used in a batch file?

Yes. Check its exit code and escape CMD metacharacters when input is variable.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.