Netstat: What It Is, How to Use It on Windows, Mac, and Linux
If you have ever wondered which apps on your computer are using the internet, which ports are open, or why a connection is failing, netstat is the tool to reach for. Short for network statistics, netstat is a command-line utility that shows active network connections, listening ports, and routing information on Windows, macOS, and Linux.
It is built into your operating system, it costs nothing, and it can answer questions that no settings screen will. In this guide, we explain what netstat is, what its output means, and how to use its most useful commands on Windows, Mac, and Linux, with practical examples you can try yourself.
What Is Netstat?
Netstat is a command-line tool that displays network connection information for your computer. It lists the connections your computer has open, the ports it is listening on, and the processes behind them. The name comes from network statistics, which is exactly what it reports.
Netstat has been part of Windows, macOS, and Unix-like systems for decades. On Windows, it is a built-in command you run in Command Prompt or PowerShell. On macOS and Linux, you run it in Terminal. On newer Linux systems, netstat is sometimes replaced by a newer tool called ss, but the concepts and most of the options are the same, and netstat is still widely used and documented.
People use netstat to check whether a server is running, to find out which program is using a particular port, to spot unusual connections that might be malware, and to troubleshoot network problems. If a website will not load or an app cannot connect, netstat can tell you whether the problem is on your computer or further away.
How to Read Netstat Output
When you run netstat, it prints a table. Each row is a connection, and each column tells you something about it. The exact columns vary slightly by operating system, but the main ones are the same.
The protocol column shows whether the connection uses TCP or UDP. TCP is used for connections that need to be reliable, such as web browsing and email. UDP is used for things where speed matters more than reliability, such as video calls and online games. The local address column shows your computer’s address and the port number after the colon. The foreign address column shows the address and port of the other end of the connection. The state column, shown for TCP, tells you what stage the connection is in.
The most common states are LISTENING, which means a program is waiting for incoming connections on that port; ESTABLISHED, which means a connection is currently open; TIME_WAIT, which means a connection has just closed and is waiting before the port is reused; and CLOSE_WAIT, which means the other end has closed the connection and your computer is finishing up. A large number of connections in TIME_WAIT is normal after heavy browsing. A program stuck in LISTENING on a port you do not expect is worth investigating.
How to Use Netstat on Windows
On Windows, open Command Prompt as an administrator for the most complete information. Press the Windows key, type cmd, right-click Command Prompt, and choose Run as administrator. Then try these commands.
Start with netstat -ano. This is the most useful form of the command. The -a option shows all connections and listening ports, -n shows addresses and port numbers instead of names, which is faster, and -o shows the process ID, or PID, of the program behind each connection. Look for the PID of a connection you are interested in, then open Task Manager, go to the Details tab, and find the same PID to see which program it belongs to.
To find out which program is using a specific port, use netstat -ano | findstr :8080, replacing 8080 with the port you care about. This is the fastest way to answer the common question of why a port is already in use when you try to start a server or an app.
To see only the programs that are listening for connections, use netstat -an | findstr LISTENING. To refresh the output every few seconds, add an interval, such as netstat -ano 5, which updates the display every five seconds until you press Ctrl+C. That is useful when you are watching a connection appear and disappear.
If a connection looks suspicious, note its foreign address and process ID, check the program in Task Manager, and run a malware scan if you do not recognise it.
How to Use Netstat on Mac and Linux
On a Mac, open Terminal from Applications, then Utilities, and run netstat -an to see all connections and listening ports. Add -p tcp to show only TCP connections, or -p udp for UDP. To see which processes own the connections, use sudo lsof -i -P, which lists the program, the protocol, and the port for each network connection. You will need to enter your administrator password.
On Linux, open a terminal and run netstat -tulpn. The options mean: -t for TCP, -u for UDP, -l for listening sockets only, -p to show the program name, and -n to show numbers instead of names. This is the quickest way to see which services are running on your Linux machine and which ports they use. If netstat is not installed, your distribution may use ss -tulpn instead, which produces the same kind of output and is the modern replacement.
On both Mac and Linux, you can also use netstat -r to show the routing table, which tells you how your computer sends traffic to other networks. The default route, usually listed as default or 0.0.0.0, should point to your router. If it does not, that is a clue that your network settings are wrong.
Common Netstat Commands and What They Do
The table below summarises the commands you will use most often. Learn these few and you can answer most everyday questions about your network.
- netstat -a: shows all active connections and listening ports.
- netstat -n: shows addresses and ports as numbers instead of names, which is faster.
- netstat -o (Windows): shows the process ID behind each connection.
- netstat -b (Windows, as administrator): shows the name of the program behind each connection.
- netstat -e (Windows): shows Ethernet statistics, such as bytes sent and received and errors.
- netstat -r: shows the routing table.
- netstat -s: shows statistics for each protocol, including TCP, UDP, and ICMP.
- netstat -an | findstr :443 (Windows): shows connections on port 443, the usual HTTPS port.
Combine options as you need them. On Windows, netstat -ano is the everyday workhorse. On Linux, netstat -tulpn is the equivalent. Memorise one of those for your system and you will rarely need anything else.
Practical Examples: Finding Problems with Netstat
Here are three common situations where netstat saves time. First, an app says a port is already in use. Run netstat -ano on Windows or ss -tulpn on Linux, find the port, and identify the program using it. You can then close that program or change the port your app uses.
Second, your internet is slow and you suspect an app is uploading in the background. Run netstat and look at the ESTABLISHED connections. If a program you do not recognise has many open connections, or is connected to an unfamiliar server, investigate it. Your router is part of this picture too: if you need to check its settings, our guide to logging in to your 192.168.1.1 router shows how to reach its admin page, and our guide to finding your network security key helps you confirm you are on the right network.
Third, you are setting up a server and want to check that it is actually listening. Run netstat and look for a LISTENING entry on the port your server should use. If it is not there, the server has not started or is bound to the wrong address. If it is there but you still cannot connect, the problem is more likely to be a firewall or your router’s port forwarding than the server itself. It also helps to know which hardware is involved: a server listens through your computer’s network hardware, which is explained in our guide to the network interface card.
Netstat vs Other Network Tools
Netstat is not the only way to look at network connections. On Windows, Resource Monitor has a Network tab that shows the same information in a graphical form, and it is easier to read if you prefer not to use the command line. On macOS, Activity Monitor shows network usage per app, though not the detailed connection list that netstat gives.
For a quick check of whether you can reach a server, ping is the right tool. For tracing the route your traffic takes, use tracert on Windows or traceroute on Mac and Linux. For looking at the actual data in a connection, Wireshark is the professional choice, but it is far more complex than netstat. Think of netstat as the middle ground: more detail than a settings screen, much simpler than a packet analyser, and always available without installing anything.
Frequently Asked Questions
What does netstat stand for?
Netstat stands for network statistics. It is a command-line tool that shows active network connections, listening ports, routing tables, and protocol statistics on Windows, macOS, and Linux.
How do I find which program is using a port?
On Windows, run netstat -ano and note the process ID for the port, then find that ID in Task Manager. On Mac, use sudo lsof -i -P. On Linux, run netstat -tulpn or ss -tulpn, which shows the program name directly.
Is netstat still used, or has it been replaced?
Netstat is still built into Windows and macOS and is widely used. On modern Linux systems, the ss command is the recommended replacement, but netstat is still available in the net-tools package and its output is familiar to most administrators.
Can netstat show me if someone is connected to my computer?
Netstat shows connections to your computer, including ESTABLISHED connections from other addresses. If you see a connection you do not recognise, note the address and the program behind it, and investigate before assuming the worst. Many connections are normal background traffic from your own apps and services.
Why does netstat show so many TIME_WAIT connections?
TIME_WAIT means a connection has closed and the port is being held briefly before it is reused. It is a normal part of TCP and is common after browsing, especially on pages that load many resources. It is only a concern if the number keeps growing without new browsing.
Final Thoughts
Netstat is a small tool with a big payoff. In one command, it tells you which programs are talking to the internet, which ports are open, and whether a server is actually listening. Learn netstat -ano on Windows or netstat -tulpn on Linux, and you will be able to diagnose a surprising number of network problems without guessing. The next time an app cannot connect or a port is already in use, open a terminal and let netstat show you what is really happening.
-
-
-
-
-
Show Comments[…] you are checking your connection while you track, a tool such as Netstat can help you see what your own network is doing, and MU-MIMO explains how modern Wi-Fi routers […]
[…] the website owner. To check whether your own connection is behaving normally, a tool such as Netstat can show you which connections your computer is making, which can help you spot a program that is […]
[…] general network checks while you troubleshoot, our guide to Netstat explains how to see which connections and ports your computer is using, which can help you confirm […]
[…] other Windows command-line tools that help with troubleshooting, our guide to Netstat explains how to check network connections on Windows, Mac, and Linux, and our guide to KB5065426 […]
[…] your connection is dropping packets, which is a common cause of streaming errors. Our guide to Netstat explains how to use a built-in tool to inspect network connections on Windows, Mac, and Linux, […]