Windows CMD Netstat: How to Use It
In this article
To see active network connections and listening ports in Windows, open Command Prompt and type netstat -ano, then press Enter. The -a shows all connections and listening ports, -n shows addresses and ports numerically (faster, no DNS lookups), and -o adds the owning process ID (PID) so you can match each connection to a program in Task Manager. That single command answers most questions about what your PC is talking to and what is listening for incoming traffic.
What You'll Need
- A Windows PC (Windows 10 or Windows 11; the command works on older versions too).
- Command Prompt. You do not need to run it as administrator for basic
netstatoutput, but an elevated prompt avoids some permission-related gaps and is required if you later want to act on a PID with tools liketaskkill. - No extra software.
netstatis built into Windows.
Step-by-Step
- Open Command Prompt. Press the Windows key, type
cmd, and click Command Prompt. For full visibility, right-click it and choose Run as administrator. The window that opens is where you will type every command below. - Run the basic all-connections view. Type
netstat -aand press Enter. You will see two tables: Active Connections (established sessions) and TCP/UDP listening ports. A state of LISTENING means a program is waiting for incoming connections; ESTABLISHED means a live connection; TIME_WAIT and CLOSE_WAIT are normal teardown states. - Switch to numeric output for speed and clarity. Type
netstat -an. The-nflag stops Windows from resolving IP addresses to host names and port numbers to service names, so the command returns almost instantly and shows raw numbers such as192.168.1.50:52344and142.250.72.14:443. This is the version to use when you are diagnosing a problem, because name resolution can hang for many seconds on a slow network. - Add the process ID. Type
netstat -ano. The extra column on the right is the PID of the process that owns each connection. Note a PID you want to investigate. - Match the PID to a program. Open Task Manager (Ctrl+Shift+Esc), go to the Details tab, and sort by PID. Find the number from the
netstatoutput; the Image Name column tells you which executable it is. If the Details tab is not visible, click More details first. This is how you answer “which app is using port 8080?” without guesswork. - Filter the output. Pipe
netstatthroughfindstrto narrow results. For example,netstat -ano | findstr :443shows only connections involving port 443, andnetstat -ano | findstr LISTENINGshows only listening ports. This is far easier than scrolling through hundreds of lines. - Check a specific protocol or interval. Use
netstat -ano -p tcpto limit output to TCP, ornetstat -ano 5to refresh every five seconds until you press Ctrl+C. The interval form is useful for watching a connection appear or disappear while you reproduce a problem. - Read the output correctly. The Local Address column is your PC's IP and port; the Foreign Address column is the remote endpoint. A foreign address of
0.0.0.0:0on a listening line means the socket is bound to all interfaces. For UDP lines there is no state column, because UDP is connectionless; do not expect to see ESTABLISHED there.
Common Mistakes
- Forgetting
-nand assuming the command is frozen. Without it, Windows tries to reverse-resolve every address, which can take a long time on a busy machine. If output stalls, press Ctrl+C and rerun with-n. - Confusing the local and foreign columns. People often read the remote port as the local one. The port your service listens on is in the Local Address column.
- Expecting
netstatto show which website a process is visiting. It shows IP addresses and ports, not URLs or page content. You can look up an IP, but the command itself does not reveal the domain. - Running an elevated command and forgetting it. An administrator prompt can behave differently for some tools; close it when you are done rather than leaving it open.
- Assuming every ESTABLISHED line is suspicious. Browsers, cloud sync clients, and Windows itself keep many connections open. Judge by the process name, not by the count.
Tips
- Save long output to a file with
netstat -ano > connections.txt, then open it in Notepad and search at leisure. - Combine with
tasklistto map PIDs to names without leaving the prompt:tasklist | findstr 1234(replace 1234 with the PID). - To see the routing table, use
netstat -r; to see interface statistics, usenetstat -e. Both are part of the same tool and need no extra install. - If you only care about listening ports,
netstat -an | findstr LISTENINGis the quickest check for a service that should be running. - Remember that labels and column widths can differ slightly between Windows versions; the meaning of the columns stays the same.
Troubleshooting
- “netstat is not recognized.” You are probably in PowerShell with a restricted path or in a different shell. Open a fresh Command Prompt from the Start menu and try again. If it still fails, the system PATH may be damaged; running
C:\Windows\System32\netstat.exedirectly confirms whether the file exists. - Output is empty or very short. Run the prompt as administrator. Some connections owned by other users or system services may not appear in a standard prompt.
- A port is listed as in use but no program appears in Task Manager. The owning process may have exited between the two checks, or it may be a system service. Rerun
netstat -anoand match the PID again; if the PID is gone, the socket is in teardown and will clear shortly. - The command hangs. Press Ctrl+C, then rerun with
-nto skip DNS lookups. A very large number of connections can also slow the display; filter withfindstr. - You want to stop a process using a port. Identify the PID, confirm in Task Manager that it is the program you mean, then use
taskkill /PID 1234 /Fin an elevated prompt. This ends the process and any unsaved work in it is lost, so close the app normally first if you can.
Frequently Asked Questions
What does netstat -ano actually show?
All active TCP connections and listening TCP/UDP ports, with addresses and ports shown as numbers (-n) and the owning process ID added (-o). It is the standard first command for checking what is listening on a Windows PC.
Do I need to be an administrator to run netstat?
No for basic viewing, but an elevated Command Prompt gives more complete results and is needed if you plan to act on a PID with taskkill.
How do I find which program is using a specific port?
Run netstat -ano | findstr :PORT (replace PORT with the number), note the PID in the last column, then find that PID on the Details tab of Task Manager.
Why does netstat show connections to addresses I do not recognize?
Browsers, update services, and background apps connect to many servers. Match the PID to the process name before worrying; an unfamiliar IP alone is not evidence of a problem.
Can netstat show the website or domain name?
No. It shows IP addresses and ports only. To see domains you need a different tool, such as the browser's own developer tools or a packet capture utility.
What is the difference between LISTENING and ESTABLISHED?
LISTENING means a program is waiting for incoming connections on that port. ESTABLISHED means a connection is currently open between your PC and a remote endpoint.