netstat - Check network connections

Maintained on

The netstat command is a network diagnostic command for Command Prompt. It displays current network connections, port usage, the routing table, and more.

Typical uses include checking for unexpected network connections, finding out whether a specific port is in use, and identifying the cause of network trouble.

With netstat you can also see which programs on your PC are communicating over the network and which ports they are listening on.

This article covers netstat from basic usage to advanced usage and troubleshooting.

Quick reference by purpose

Start with the command that fits your goal.

GoalCommand
List listening ports with PIDsnetstat -ano | findstr LISTENING
Find what uses a specific port (e.g., 8080)netstat -ano | findstr /c:":8080 "
Check established connectionsnetstat -ano | findstr ESTABLISHED
Show program names toonetstat -abno (administrator required)

To find the program name from a PID, use tasklist /fi "PID eq 1234".

Basic usage of the netstat command

The basic usage is as follows.

netstat

Run on its own with no options, it displays only the currently active TCP connections (listening ports and UDP are not shown).

For more detail, specify options.

netstat [-a] [-b] [-e] [-f] [-n] [-o] [-p protocol] [-q] [-r] [-s] [-t] [-x] [-y] [interval]

Basic example

First, run netstat without options.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat
Active Connections
ProtoLocal AddressForeign AddressState
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED
TCP192.168.1.100:54322XXX.XXX.XXX.XXX:80ESTABLISHED
TCP192.168.1.100:54323XXX.XXX.XXX.XXX:443ESTABLISHED
C:\users\user>

This output shows only active TCP connections.

About connection states

The “State” column shows the state of each TCP connection. Common states include ESTABLISHED (connected), LISTENING (waiting for connections), and TIME_WAIT (closing).

Main options of the netstat command

netstat has many options. This section covers the ones used most often.

Show all connections: the -a option

-a shows all active connections plus ports in the listening (LISTENING) state.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -a
Active Connections
ProtoLocal AddressForeign AddressState
TCP0.0.0.0:800.0.0.0:0LISTENING
TCP0.0.0.0:4430.0.0.0:0LISTENING
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED
UDP0.0.0.0:123:
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

With -a you can see which ports are waiting for connections.

Checking that a server is running

To confirm that a web or database server started correctly, use netstat -a and check whether the relevant port (for example 80, 443, or 3306) is in the LISTENING state.

Skip name resolution: the -n option

-n shows addresses and port numbers numerically instead of converting them to names.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -n
Active Connections
ProtoLocal AddressForeign AddressState
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED
TCP192.168.1.100:54322XXX.XXX.XXX.XXX:80ESTABLISHED
C:\users\user>

Because no name resolution is performed, it runs much faster, especially when there are many connections.

Show process IDs: the -o option

-o shows the process ID (PID) associated with each connection.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -o
Active Connections
ProtoLocal AddressForeign AddressStatePID
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED4512
TCP192.168.1.100:54322XXX.XXX.XXX.XXX:80ESTABLISHED8920
C:\users\user>

Once you know the PID, you can identify the program that is communicating. Check the PID column on the Details tab of Task Manager, or run tasklist /fi "PID eq 4512".

Using the PID

Checking the displayed PID with tasklist or Task Manager lets you identify the program that is communicating. This is useful for security monitoring.

Show executable names: the -b option

-b shows the name of the executable that created each connection or listening port.

Administrator rights required

To use the -b option, you must run Command Prompt as administrator.

- □ ×
Command Prompt Icon
Administrator: Administrator: Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -b
Active Connections
ProtoLocal AddressForeign AddressState
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED
[chrome.exe]
TCP0.0.0.0:800.0.0.0:0LISTENING
[httpd.exe]
C:\users\user>

This option is convenient because it shows directly which program is using the network. Resolving executable names takes time, so the output may take tens of seconds to finish.

Show statistics: the -s option

-s shows statistics for each protocol.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -s
IPv4 Statistics
Packets Received = 245832
Received Header Errors = 0
Received Address Errors = 12
Datagrams Forwarded = 0
TCP Statistics for IPv4
Active Opens = 3567
Passive Opens = 892
Failed Connection Attempts = 45
Reset Connections = 234
C:\users\user>

Statistics help with network performance analysis and troubleshooting.

Show the routing table: the -r option

-r displays the IP routing table.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -r
IPv4 Route Table
Active Routes:
Network DestinationNetmaskGatewayInterfaceMetric
0.0.0.00.0.0.0192.168.1.1192.168.1.10025
192.168.1.0255.255.255.0On-link192.168.1.100281
192.168.1.100255.255.255.255On-link192.168.1.100281
C:\users\user>

Checking the routing table helps you understand how network packets are forwarded.

Useful option combinations

In practice, you usually combine several options.

The -ano combination

One of the most common combinations is netstat -ano.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -ano
Active Connections
ProtoLocal AddressForeign AddressStatePID
TCP0.0.0.0:800.0.0.0:0LISTENING1234
TCP0.0.0.0:4430.0.0.0:0LISTENING1234
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED4512
UDP0.0.0.0:53:2896
C:\users\user>

This command gives you all of the following at once:

  • All connections (-a)
  • Fast display without name resolution (-n)
  • Process IDs (-o) to identify programs
A first step in troubleshooting

When a network problem occurs, running netstat -ano first to get the big picture is effective.

The -abon combination

When running as administrator, the -abon combination is very useful.

- □ ×
Command Prompt Icon
Administrator: Administrator: Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -abon
Active Connections
ProtoLocal AddressForeign AddressStatePID
TCP0.0.0.0:800.0.0.0:0LISTENING1234
[httpd.exe]
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED4512
[chrome.exe]
C:\users\user>

It shows both the process ID and the executable name, giving you more detailed information.

Continuous monitoring

If you add a number to the netstat command, it refreshes the display at that interval in seconds.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -ano 5
Active Connections
ProtoLocal AddressForeign AddressStatePID
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED4512
(refreshes every 5 seconds)
C:\users\user>
Stopping monitoring

Press Ctrl + C to stop continuous monitoring.

Practical examples

Find the process using a specific port

To find the process using a specific port number (for example 8080), combine netstat with the findstr command.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -ano | findstr /c:":8080 "
TCP0.0.0.0:80800.0.0.0:0LISTENING5432
C:\users\user>

Searching for just :8080 would also match ports such as :80801. Using /c: makes findstr treat the trailing space as part of the search string (otherwise a space means OR), so use /c:":8080 ". This can also match a remote port 8080 in the Foreign Address column, so check the Local Address column.

Once you have the PID, tasklist /fi "PID eq 5432" shows the program name. To end the process, use taskkill /PID 5432.

Show only ESTABLISHED connections

To check only established connections:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -ano | findstr ESTABLISHED
TCP192.168.1.100:54321XXX.XXX.XXX.XXX:443ESTABLISHED4512
TCP192.168.1.100:54322XXX.XXX.XXX.XXX:80ESTABLISHED8920
C:\users\user>

Show only LISTENING ports

To check only the ports that are waiting for connections:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -ano | findstr LISTENING
TCP0.0.0.0:800.0.0.0:0LISTENING1234
TCP0.0.0.0:4430.0.0.0:0LISTENING1234
TCP0.0.0.0:33060.0.0.0:0LISTENING2345
C:\users\user>
Checking after starting a server

After starting a web or database server, get into the habit of running netstat -ano | findstr LISTENING to confirm the port is open.

Troubleshooting cases

Checking for a port conflict

When you get an error such as “port already in use”, netstat tells you which process is using that port.

For example, if starting a web server on port 80 fails:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>netstat -ano | findstr /c:":80 "
TCP0.0.0.0:800.0.0.0:0LISTENING3456
C:\users\user>

You can see that the process with PID 3456 is using port 80.

Checking suspicious outbound connections

If you have security concerns, run netstat -ano | findstr ESTABLISHED as shown above to check connections to external hosts.

If there are connections to IP addresses you do not recognize, check the process with that PID and take action if necessary.

Responding to suspicious connections

Web browsers and background programs talk to many external IP addresses, such as CDNs and cloud services, so an unfamiliar address is not necessarily malicious. Identify the program from its PID, and if you do not recognize it, scan it with security software.

Main connection states

It is important to understand the main TCP connection states shown in the netstat output.

StateDescription
LISTENINGWaiting for connections. A server is waiting for clients
ESTABLISHEDA connection is established and data can be exchanged
TIME_WAITWaiting after the connection was closed, before it is fully released
CLOSE_WAITThe other side closed the connection and the local application has not closed it yet
SYN_SENTA connection request has been sent
SYN_RECEIVEDA connection request has been received
FIN_WAIT_1Closing the connection (stage 1)
FIN_WAIT_2Closing the connection (stage 2)
LAST_ACKThe local side closed and is waiting for the last acknowledgment
About the TIME_WAIT state

Many TIME_WAIT entries mean that many connections were opened and closed in a short time. This is normally harmless and they disappear after a while (about 2 minutes by default). On the other hand, if CLOSE_WAIT entries stay for a long time, the application may not be closing its connections.

Summary

This article covered the netstat command from basic to advanced usage.

Key points:

  • netstat is the basic command for checking network connections
  • -a shows all connections
  • -n skips name resolution for faster output
  • -o shows process IDs
  • -b (administrator) shows executable names
  • Combine with findstr to filter by port or state

netstat is an essential tool for network troubleshooting and security monitoring. Use it regularly to get a feel for your network’s state.

Practice quiz

Practice Problem

Which command is most appropriate for displaying all connections, including ports in the listening (LISTENING) state?

回答がサーバーに送信されることはありません
#Command Prompt #Batch File #Network #Troubleshooting #Security