Why you need to know which ports are open

An open port is a doorway on your computer that listens for incoming connections from the internet or your local network. Some ports need to be open — your web browser uses port 443 to reach HTTPS websites, for example. But ports you don't recognize or didn't intentionally open are a real security problem, because they let someone else's software talk directly to yours.

Checking your open ports tells you what's actually listening on your machine right now. You might find that a program you installed opened ports you didn't know about, or that something you uninstalled left a port still listening. Either way, you can't defend what you don't see.

This is different from checking your router's open ports — that's a separate task. Here we're looking at what's open on the computer itself.

Key Takeaways

  • Open ports are connection points that programs use to send and receive data; some are necessary, but unknown open ports are a security risk.
  • Windows users can use the built-in Command Prompt with the netstat command to see which ports are listening and which program is using each one.
  • Mac and Linux users can use Terminal with the lsof or netstat command to list open ports and their associated processes.
  • Port numbers below 1024 are reserved for system services; ports above 1024 are usually opened by user-installed programs.
  • If you find an open port you don't recognize, search the port number and process name together to learn what it does before closing it.

How to check open ports on Windows

Open Command Prompt as an administrator. Click the Start menu, type cmd, right-click "Command Prompt," and select "Run as administrator." Windows will ask for permission — click Yes.

Type this command and press Enter:

netstat -ano

The output shows every active connection and listening port on your computer. The columns are: Proto (protocol, usually TCP or UDP), Local Address (your computer's address and port number), Foreign Address (where the connection is going, if active), State (whether it's listening or connected), and PID (the process ID number of the program using that port).

Look for rows that say "LISTENING" in the State column. These are the open ports. The Local Address column shows the port number — for example, "127.0.0.1:3306" means port 3306 is open, but only to your own computer. "0.0.0.0:80" means port 80 is open to anyone on the network.

To find out which program is using a port, note the PID number from the last column. Then open Task Manager (press Ctrl+Shift+Esc), click the "Details" tab, and look for that PID number in the list. The program name will be in the same row.

How to check open ports on Mac and Linux

Open Terminal. On Mac, press Command+Space, type "Terminal," and press Enter. On Linux, use your process menu or press Ctrl+Alt+T.

Type this command and press Enter:

lsof -i -P -n

This shows all open network connections and listening ports. The output includes the program name (COMMAND column), the PID, and the port number (NAME column). Look for rows that say "LISTEN" — those are your open ports.

If lsof is not installed on your Linux system, use netstat -tuln instead. This shows listening ports and their associated programs, though the format is slightly different.

Understanding what you're looking at

Port numbers range from 0 to 65535. Ports 0 to 1023 are reserved ports — they're assigned to specific system services like HTTP (port 80), HTTPS (port 443), SSH (port 22), and DNS (port 53). If you see an unfamiliar program using a reserved port, that's worth investigating.

Ports 1024 and above are dynamic ports, usually opened by user-installed programs. Common ones include 3306 (MySQL database), 5432 (PostgreSQL), 8080 (web servers), and 27017 (MongoDB). If you installed database software or a development server, you'll see these.

The address "127.0.0.1" or "localhost" means the port is only listening to your own computer — nothing from the internet or network can reach it. The address "0.0.0.0" or "::" means the port is listening to everyone. The address of your actual network IP (like 192.168.1.100) means it's listening only to your local network.

What to do if you find an unfamiliar open port

Write down the port number and the program name. Search online for "[port number] [program name]" — for example, "port 5900 vnc" or "port 445 windows." This usually tells you what the program does and whether it's supposed to be open.

If the program is something you installed (like a database, web server, or development tool), the port is probably intentional. If it's a program you don't recognize, search the program name itself. Malware sometimes uses unusual port numbers, but so do legitimate programs you may have forgotten about.

If you're certain the port shouldn't be open, close it by uninstalling the program that's using it, or by changing the program's settings to stop listening on that port. Don't just close the port in your firewall — that hides the problem without solving it. The program will keep trying to use it.

Checking ports regularly

Run this check once a month, or whenever you install new software. Keep a straightforward list of which ports should normally be open on your computer — the ones you recognize and intentionally use. Then when you run the check again, you'll spot anything new when ready.

If you see a port that wasn't there before and you didn't install anything new, that's a sign something else changed. It might be a software update that added a feature, or it might be something you need to investigate further.

Frequently Asked Questions

Is it dangerous to have open ports?

Only if you don't know what they are. A port listening on 127.0.0.1 (localhost only) is safe — nothing from outside your computer can reach it. A port listening on 0.0.0.0 that belongs to a program you didn't install is a real risk. Knowing what's open is the first step to deciding whether it's safe.

Can I just close all open ports?

No. Your computer needs some ports open to work — your web browser, email, and other network programs depend on them. Closing all ports would disconnect you from the internet. Instead, close only the ports that belong to programs you don't use or don't recognize.

What if I see a port I don't remember opening?

Search the program name and port number online first. Many legitimate programs open ports automatically — Spotify, Discord, and Zoom all do this. If you use the program, the port is supposed to be there. If you don't use it, uninstall the program.

Do I need to check ports on my phone?

Phones work differently than computers. They don't have a traditional port system the same way, and the operating system controls what can listen on ports much more strictly. Checking ports on a Windows PC or Mac is more useful for home network security.

What's the difference between TCP and UDP ports?

TCP is connection-based — it checks that data arrived safely. UDP is faster but doesn't check. Most programs use TCP. UDP is common for video calls, online games, and streaming where speed matters more than perfection. Both can be security risks if unknown, so check both.