What an open port is and why you might need to check

A port is a virtual endpoint on your computer where programs send and receive data over a network. When you visit a website, your browser connects to port 80 or 443 on a web server. When you use email, your email client connects to port 25, 587, or 993 depending on what your email provider uses. A port is open when your computer is actively listening on that port and will accept incoming connections.

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 machine. If you're setting up a game server, a web server, or any other service that needs to accept connections from other computers, checking the port tells you whether the setup worked.

Key Takeaways

  • On Windows, use the Command Prompt command netstat -ano to see all open ports and which programs are using them.
  • On Mac or Linux, use the Terminal command lsof -i or netstat -tuln to list open ports.
  • To check if a specific port on a remote computer is open, use telnet hostname portnumber or online port-checking tools.
  • A port showing as "LISTENING" means it's open; "ESTABLISHED" means an active connection exists; "TIME_WAIT" or "CLOSE_WAIT" means the port is closing.

Checking open ports on Windows

Open the Command Prompt by pressing Windows key + R, typing cmd, and pressing Enter. Type netstat -ano and press Enter. You'll see a list of all active connections and listening ports on your computer.

Look for the column labeled "State". Ports that show LISTENING are open and waiting for incoming connections. The "Local Address" column shows the port number (the number after the colon). The "PID" column at the far right shows the process ID of the program using that port. To find out which program owns a PID, open Task Manager (Ctrl + Shift + Esc), click the "Processes" tab, then click "View" and check "PID (Process ID)". Match the PID from netstat to find the program name.

If you want to check a specific port, type netstat -ano | findstr :portnumber where you replace "portnumber" with the actual port (for example, netstat -ano | findstr :8080). This filters the output to show only that port.

Checking open ports on Mac and Linux

Open Terminal. On Mac, type lsof -i and press Enter. This shows all open network connections and the programs using them. Look for the "NAME" column, which shows the port number in the format "localhost:portnumber" or "hostname:portnumber".

On Linux, type netstat -tuln and press Enter. The "Local Address" column shows the port, and "State" shows whether it's LISTENING. If you want to see which program is using each port on Linux, type sudo netstat -tulnp (the sudo command requires administrator access, and the p flag adds the program name).

To check a specific port on Mac or Linux, type lsof -i :portnumber (Mac) or netstat -tuln | grep :portnumber (Linux), replacing "portnumber" with the actual port number.

Checking if a port is open on another computer

If you want to know whether a port is open on a different computer (not your own), you can use Telnet. On Windows, open Command Prompt and type telnet hostname portnumber, replacing "hostname" with the computer's address or IP address and "portnumber" with the port you want to check. For example, telnet example.com 80. If the port is open, the window will go blank or show a cursor. If the port is closed, you'll see a "Connection refused" or "Could not open connection" message.

On Mac or Linux, the Telnet command works the same way. If Telnet isn't installed, you can use nc -zv hostname portnumber (the nc command, short for netcat). The -z flag scans without sending data, and -v gives verbose output.

Online port-checking tools also exist — you enter a hostname and port number, and the tool attempts to connect from its server. These are useful if your own computer's firewall is blocking outbound connections, but they only tell you whether the port is reachable from the internet, not from your local network.

Understanding port states and what they mean

When you run netstat or lsof, the "State" column shows what the port is doing. LISTENING means the port is open and waiting for incoming connections — this is what you're usually looking for. ESTABLISHED means an active connection is currently using that port. TIME_WAIT or CLOSE_WAIT means the connection is in the process of closing and the port will become available shortly.

If you don't see a port listed at all, it's closed — no program is listening on it. If you started a service and expected it to open a port but the port doesn't appear in the list, the service either didn't start correctly, is configured to use a different port, or is only listening on localhost (your own computer) rather than on all network interfaces.

Why a port might not be open even when a program is running

A program can be running but not have an open port if it's configured to listen only on localhost (127.0.0.1) instead of on all network interfaces (0.0.0.0). This means other computers can't reach it, but your own computer can. Check the program's configuration file or settings to see what address it's bound to.

Your firewall might also be blocking the port. Even if a program is listening, Windows Defender Firewall, macOS firewall, or a third-party firewall can prevent incoming connections. Check your firewall settings to see whether the program or port is blocked, and add an exception if needed. On a network, your router's firewall might also be blocking the port — you may need to forward the port in your router settings if you want computers outside your network to reach it.

Frequently Asked Questions

What's the difference between a port being open and a port being in use?

A port is "in use" when a program has claimed it and is listening on it. An "open" port is one that will accept incoming connections. These usually mean the same thing, but technically a port could be in use but not accepting connections if the program is configured that way. In practice, if netstat shows a port as LISTENING, it's both in use and open.

Is it dangerous to have ports open?

Open ports themselves aren't dangerous — they're how programs communicate. The risk comes from what's listening on the port. If a program with security vulnerabilities is listening, or if you've opened a port to a service you don't need, an attacker could potentially exploit it. Close ports you're not using, keep your software updated, and use a firewall to block unnecessary inbound connections.

How do I close a port that's open?

Find which program is using the port (using netstat or lsof), then close that program. The port will close automatically. If you want to prevent the program from opening that port again, uninstall it, disable it, or change its configuration. On Windows, you can also disable a program from starting at boot in Task Manager's "Startup" tab.

Can I check if a port is open without using the command line?

Yes. On Windows, third-party tools like CurrPorts or TCPView show open ports in a graphical window. On Mac, Network Utility (included with older macOS versions) has a port-scanning tool. Online port-checking websites also work, though they only check ports reachable from the internet. The command-line tools are faster and more reliable for checking your own computer.

What are the most common ports I should know about?

Port 80 is HTTP (websites), port 443 is HTTPS (secure websites), port 22 is SSH (remote access), port 25 and 587 are SMTP (sending email), port 993 is IMAPS (receiving email), and port 3306 is MySQL (databases). Ports 1 through 1023 are reserved for system services. Ports 49152 through 65535 are available for any program to use.