A practical guide to managing TCP and UDP ports in Windows: create firewall rules, remove unsafe rules, find listening ports, identify the process using a port, and troubleshoot blocked connections.
A network port is a numbered communication endpoint used by an application or Windows service. For example, a web server usually listens on port 80 for HTTP or port 443 for HTTPS. Remote Desktop commonly uses TCP port 3389, while DNS usually uses port 53.
When people say that a port is βopenβ in Windows, they can mean two different things:
| Meaning | What It Means | How to Check |
|---|---|---|
| A program is listening | An application or service is waiting for incoming connections on that port. | netstat, PowerShell, Resource Monitor |
| The firewall allows the port | Windows Defender Firewall has a rule that allows traffic through that port. | Windows Defender Firewall, PowerShell firewall rules |
Opening ports can be necessary for game servers, local web servers, database access, remote administration tools, file sharing, development environments, and some peer-to-peer applications. However, every open inbound port can also increase the attack surface of your PC.
25565 for a Minecraft server or 3389 for Remote Desktop.The graphical firewall console is the safest method for most users because it clearly shows the rule type, protocol, port number, network profile, and rule name.
Win + R, type wf.msc, and press Enter.8080. You can also enter a range such as 5000-5010.PowerShell is faster for administrators and useful when you need to create the same firewall rule on multiple computers.
New-NetFirewallRule -DisplayName "Allow TCP 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow -Profile Private
This example opens inbound TCP port 8080 only on the Private network profile.
New-NetFirewallRule -DisplayName "Allow UDP 27015" -Direction Inbound -Protocol UDP -LocalPort 27015 -Action Allow -Profile Private
New-NetFirewallRule -DisplayName "Allow TCP 8080 All Profiles" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow -Profile Any
-Profile Any applies the rule to Domain, Private, and Public networks. For a laptop, this can expose the port on hotel, airport, or coffee shop Wi-Fi.
You can also open ports with netsh, which works in both Windows 10 and Windows 11 and is useful in batch files.
netsh advfirewall firewall add rule name="Allow TCP 8080" dir=in action=allow protocol=TCP localport=8080 profile=private
netsh advfirewall firewall add rule name="Allow UDP 27015" dir=in action=allow protocol=UDP localport=27015 profile=private
netsh advfirewall firewall add rule name="Allow TCP 5000-5010" dir=in action=allow protocol=TCP localport=5000-5010 profile=private
To close a port, you usually need to do one of two things: remove or disable the firewall rule that allows the port, and stop the application that is listening on the port. If a service continues to run, the port may still appear as LISTENING locally, even if the firewall blocks inbound traffic.
Win + R, type wf.msc, and press Enter.Remove-NetFirewallRule -DisplayName "Allow TCP 8080"
To disable the rule instead of deleting it:
Disable-NetFirewallRule -DisplayName "Allow TCP 8080"
netsh advfirewall firewall delete rule name="Allow TCP 8080" protocol=TCP localport=8080
wf.msc and sort or filter inbound rules by Local Port, Protocol, or Enabled status.
Windows includes several built-in tools for viewing open ports and active connections. The most useful ones are netstat, PowerShell, Resource Monitor, and Windows Defender Firewall logs.
Best for a quick list of listening ports and process IDs.
netstat -ano | findstr LISTENING
Best for filtering and scripting active TCP listeners.
Get-NetTCPConnection -State Listen
Best for users who prefer a graphical interface.
resmon
netstat -ano | findstr LISTENING
The output shows the protocol, local address, port, connection state, and PID. For example:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1234
In this example, port 8080 is listening, and the process ID is 1234.
netstat -ano
Get-NetTCPConnection -State Listen | Sort-Object LocalPort | Select-Object LocalAddress,LocalPort,OwningProcess
Get-NetUDPEndpoint | Sort-Object LocalPort | Select-Object LocalAddress,LocalPort,OwningProcess
Win + R, type resmon, and press Enter.If a port is already in use, another program may fail to start. You can identify the process by matching the port number to a PID and then matching the PID to an application.
netstat -ano | findstr :8080
Look at the last number in the line. That is the process ID.
tasklist /fi "PID eq 1234"
Replace 1234 with the PID from the previous command.
Get-Process -Id 1234
taskkill /PID 1234 /F
After creating a firewall rule, you should verify whether the port is actually reachable. A successful test requires three things: a service listening on the port, a firewall rule that allows traffic, and correct network routing.
Test-NetConnection 192.168.1.10 -Port 8080
If the output shows TcpTestSucceeded : True, the TCP port is reachable from that computer.
netstat -ano | findstr :8080
Get-NetFirewallPortFilter | Where-Object {$_.LocalPort -eq "8080"}
These are common ports you may encounter while checking open ports on a Windows computer. Do not open them publicly unless you understand exactly why they are needed.
| Port | Protocol | Common Use | Security Note |
|---|---|---|---|
80 |
TCP | HTTP web traffic | Usually safe only for a configured web server. |
443 |
TCP | HTTPS web traffic | Prefer HTTPS over HTTP for public services. |
53 |
TCP/UDP | DNS | Do not expose a recursive DNS resolver publicly. |
445 |
TCP | SMB file sharing | Should not be exposed to the internet. |
3389 |
TCP/UDP | Remote Desktop | Use VPN, strong authentication, and account lockout policies. |
5985 |
TCP | Windows Remote Management over HTTP | Use only on trusted networks. |
5986 |
TCP | Windows Remote Management over HTTPS | Requires proper certificate configuration. |
If an online port checker or another computer still cannot connect, use this checklist.
| Problem | What to Check | Fix |
|---|---|---|
| No service is listening | netstat -ano | findstr :PORT |
Start the application or service that should use the port. |
| Wrong protocol | TCP vs UDP | Create the rule for the correct protocol, or create separate TCP and UDP rules. |
| Wrong network profile | Private/Public/Domain | Change the rule profile or switch the network type to Private if appropriate. |
| Router blocks inbound traffic | Port forwarding settings | Forward the port to the correct local IP address. |
| Local IP changed | PC's current IPv4 address | Use a DHCP reservation or static IP for the server PC. |
| ISP uses CGNAT | Router WAN IP vs public IP | Request a public IP, use IPv6 if available, or use a VPN/tunnel solution. |
| Third-party security software blocks traffic | Antivirus firewall settings | Add an allow rule in the third-party firewall or temporarily test with it disabled. |
netstat shows applications listening locally. Deleting a firewall rule blocks inbound traffic, but it does not stop the application. Stop the related service or program if you want the port to disappear from the listening list.netstat -ano | findstr LISTENING. For a graphical view, press Win + R, run resmon, open the Network tab, and expand Listening Ports.For most users, the best way to open a port is through Windows Defender Firewall with Advanced Security using wf.msc. It provides a clear interface and reduces the chance of creating an overly broad rule. For administrators, PowerShell is faster and easier to automate.
Open only the ports you need, limit rules to the correct network profile, use descriptive rule names, and regularly review listening ports with netstat, PowerShell, or Resource Monitor. If a service must be available from the internet, secure it carefully and avoid exposing sensitive ports such as SMB or Remote Desktop without additional protection.