What it means when a port is open
A port is a numbered channel that your computer uses to send and receive data over a network. When a port is "open," it means a program on your computer is actively listening on that port and ready to receive incoming connections. When it's "closed," nothing is listening there — incoming traffic gets rejected.
You might need to check if a port is open to troubleshoot why a program isn't connecting, to verify that a service you started is actually running, or to understand what's listening on your computer. The method you use depends on whether you're checking a port on your own machine or testing whether someone else can reach a port on your computer from the internet.
Key Takeaways
- On Windows, use the Command Prompt with netstat -ano to see all open ports and which programs are using them.
- On Mac or Linux, use the Terminal with lsof -i -P -n to list open ports and their associated processes.
- To test whether a specific port is open and responding, use telnet or nc (netcat) from the command line.
- If you're checking from outside your network, you need an online port scanner tool, because your router's firewall may block ports even if they're open on your computer.
- A port can be open on your computer but still unreachable from the internet if your firewall or router is blocking it.
Check open ports on Windows
The fastest way to see all open ports on a Windows machine is through the Command Prompt. Press the Windows key, type cmd, and press Enter to open Command Prompt. Then type this command and press Enter:
netstat -ano
This shows you a list of all active connections and listening ports. The columns are: Protocol (TCP or UDP), Local Address (your computer's IP and port number), Foreign Address (where the connection is going), State (whether it's listening, established, or closing), and PID (the process ID of the program using that port). To find out which program owns a specific port, look at the PID number, then open Task Manager (Ctrl+Shift+Esc), go to the Details tab, and search for that PID number.
If you want to filter the results to see only listening ports, type this instead:
netstat -ano | findstr LISTENING
Check open ports on Mac or Linux
Open the Terminal application. On Mac, press Command+Space, type terminal, and press Enter. On Linux, use your system's application menu or press Ctrl+Alt+T. Then type this command and press Enter:
lsof -i -P -n
This lists all open network connections. The output shows the command name (the program using the port), the PID, the user running it, the file descriptor, the protocol, and the local and remote addresses. The -P flag shows port numbers instead of service names, and -n shows IP addresses instead of hostnames, making the output easier to read.
If you want to see only listening ports (not established connections), add a filter:
lsof -i -P -n | grep LISTEN
Test if a specific port is responding
Seeing that a port is open on your computer is different from testing whether it's actually responding to connections. To test this, use telnet or netcat.
On Windows, open Command Prompt and type:
telnet localhost 8080
Replace 8080 with the port number you want to test. If the port is open and responding, the screen will go blank or show a connection message. If it's closed, you'll see a connection refused error. Press Ctrl+] and then type quit to exit telnet.
On Mac or Linux, use netcat instead. Open Terminal and type:
nc -zv localhost 8080
The -z flag scans without sending data, and -v gives verbose output. A successful connection shows "succeeded" or "open." A failed connection shows "refused" or "timed out."
Check if a port is reachable from outside your network
If you need to know whether someone outside your home or office network can reach a port on your computer, you can't test it from your own machine — you need an outside perspective. Use an online port scanner tool like CanYouSeeMe.org or Canyouseeme.org. These tools attempt to connect to your computer from the internet and report whether the port is reachable.
To use one of these tools, you'll need to know your public IP address. The tool usually displays it for you, or you can visit WhatIsMyIPAddress.com. Then enter your public IP and the port number you want to test. The tool will try to connect and tell you if it succeeded.
Keep in mind that even if a port is open on your computer, it may not be reachable from the internet because your router or firewall is blocking it. This is actually the default behavior for security — most home routers block incoming connections unless you specifically configure port forwarding to allow them through.
Understand the difference between open and reachable
A port can be open on your computer but still unreachable from the internet. This happens in layers: your computer has a firewall, your router has a firewall, and your internet service provider may have restrictions too. When you run netstat or lsof, you're seeing what's open on your computer itself. When you use an online port scanner, you're testing whether traffic can actually reach that port from outside.
If a port shows as listening but an online scanner says it's closed, your router's firewall is likely blocking it. To allow outside access, you'd need to configure port forwarding in your router settings — but only do this if you understand the security implications and trust the service listening on that port.
Common reasons a port appears closed when it shouldn't be
The program using the port crashed or stopped running. Check that the service you expect to be listening is actually still running. Restart it and run your port check again.
The program is listening on a different port than you think. Double-check the program's configuration or documentation to confirm which port it should be using. Some programs let you change the port in their settings.
The program is listening only on localhost (127.0.0.1) instead of on all network interfaces. This means it can only be reached from your own computer, not from other machines on your network. Check the program's configuration to see if you can change it to listen on 0.0.0.0 or a specific network interface.
Your firewall is blocking the port. On Windows, check Windows Defender Firewall settings. On Mac, check System Preferences > Security & Privacy > Firewall. On Linux, check your firewall rules with sudo ufw status (if using UFW) or sudo iptables -L (if using iptables).
Frequently Asked Questions
Why do I need to know if a port is open?
You might need to check if a port is open to confirm that a service you started is actually running, to troubleshoot why a program can't connect to another computer, or to verify that a server is listening before you try to connect to it. It's also useful for security — knowing what ports are open on your computer helps you spot unexpected services.
What's the difference between TCP and UDP ports?
TCP is a connection-based protocol — it establishes a connection before sending data and guarantees delivery. UDP sends data without establishing a connection first and doesn't may provide delivery. Most common services use TCP, but some (like DNS and online games) use UDP. Both can be open on your computer at the same time.
Can I close a port that's open?
Yes. Stop the program that's using the port, and the port will close. If you want to prevent a program from opening a port in the future, uninstall it or disable the service in your system settings. You can also block a port at the firewall level without stopping the program, though the program will still be trying to use it.
Is it dangerous to have ports open?
Open ports themselves aren't dangerous — they're how your computer communicates. The risk comes from what's listening on those ports. If a port is open and running a service with a security vulnerability, an attacker could exploit it. Keep your software updated, only open ports you actually need, and use a firewall to block ports you don't want exposed to the internet.
What if telnet or netcat isn't installed on my computer?
On Windows, telnet may not be enabled by default. Go to Control Panel > Programs > Programs and Features > Turn Windows features on or off, find Telnet Client, check the box, and click OK. On Mac or Linux, install netcat using your package manager: brew install netcat on Mac, or sudo apt install netcat on Ubuntu/Debian.