A program can be reached from the Internet only when two things are true: the program waits for connections on a port, and the Windows firewall lets that port through. This guide shows how to list the programs that wait, how to test from outside which ports really answer, and how to find the firewall rule behind an open port.

The examples use Windows Server 2025. Run the commands in PowerShell as Administrator: right-click the Start button and choose Terminal (Admin).


1. Which Programs Wait for Connections

Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, @{n="Process";e={(Get-Process -Id $_.OwningProcess).ProcessName}} | Sort-Object LocalPort, LocalAddress | Format-Table -AutoSize

The answer is long. These are its most important lines on a server with one extra program, Plex Media Server:

LocalAddress    LocalPort Process
------------    --------- -------
0.0.0.0               135 svchost
203.0.113.10          139 System
::                    445 System
0.0.0.0              3389 svchost
::                   5985 System
::                  32400 Plex Media Server
127.0.0.1           32401 Plex Media Server
::                  47001 System
0.0.0.0             49664 lsass
  • LocalAddress 0.0.0.0 or :: means all addresses of the server. Such a port can be reached from outside if the firewall allows it.
  • 127.0.0.1 means the server itself only. Nobody else can connect to this port.
  • Process is the program. svchost and System are parts of Windows.

A Windows server has these entries even when you installed nothing:

PortWhat it is
3389Remote Desktop.
135, 139, 445Windows networking and file sharing.
5985, 47001Remote management of Windows.
49664 and higherServices of Windows.

To see which Windows service is behind a svchost line, take the port and ask for the service:

$id = (Get-NetTCPConnection -State Listen -LocalPort 3389 | Select-Object -First 1).OwningProcess
tasklist /svc /fi "PID eq $id"
Image Name                     PID Services
========================= ======== ============================================
svchost.exe                   1468 TermService

TermService is Remote Desktop Services. For a program you do not know, (Get-Process -Id $id).Path shows the file it runs from.

2. Test From Outside Which Ports Answer

That a program listens does not mean that the port is open. On the example server 27 entries listen, but only two ports answer from the Internet: 3389 of Remote Desktop and 32400 of Plex Media Server. The firewall stops the rest.

Test it from your own Windows computer, not from the server. Use the address of your server and the port:

Test-NetConnection 203.0.113.10 -Port 3389 | Select-Object RemotePort, TcpTestSucceeded | Format-List
RemotePort       : 3389
TcpTestSucceeded : True

True means that the port answers. A port that is closed or stopped by the firewall gives False. That answer can take up to half a minute:

RemotePort       : 8080
TcpTestSucceeded : False

3. Find the Firewall Rule Behind a Port

The firewall blocks every incoming connection that no rule allows. This shows the rules for one port:

Get-NetFirewallPortFilter -Protocol TCP | Where-Object LocalPort -eq 3389 | Get-NetFirewallRule | Where-Object { $_.Direction -eq "Inbound" } | Select-Object DisplayName, Enabled, Action, Profile
DisplayName                         Enabled Action Profile
-----------                         ------- ------ -------
Remote Desktop - User Mode (TCP-In)    True  Allow     Any

Enabled True with Action Allow opens the port. The same command for port 445 shows why file sharing does not answer from outside, although Windows listens on it. All its rules are switched off:

DisplayName                                     Enabled Action Profile
-----------                                     ------- ------ -------
Netlogon Service (NP-In)                          False  Allow     Any
Remote Event Log Management (NP-In)               False  Allow     Any
Remote Service Management (NP-In)                 False  Allow     Any
File and Printer Sharing (Restrictive) (SMB-In)   False  Allow     Any
File and Printer Sharing (SMB-In)                 False  Allow     Any

Some rules allow a program instead of a port. They do not appear in the list above. Search them by a part of the program's name:

Get-NetFirewallApplicationFilter | Where-Object Program -like "*Plex*" | Get-NetFirewallRule | Select-Object DisplayName, Enabled, Direction, Action
DisplayName        Enabled Direction Action
-----------        ------- --------- ------
Plex DLNA Server      True   Inbound  Allow
Plex Media Server     True   Inbound  Allow
Plex Script Host      True   Inbound  Allow
Plex Tuner Service    True   Inbound  Allow

Programs often add such rules themselves when you install them. That is why the test from outside in step 2 is the one that counts.

4. What to Do

What you foundWhat to do
Remote Desktop answers for everybodyAllow it only from your own addresses: Allow Remote Desktop Only From Your IP Addresses.
A port of a program answers, and you do not need it from outsideSwitch its rule off: Disable-NetFirewallRule -DisplayName "Plex Media Server", with the name from step 3. Or remove the program.
Your program should answer, but the test says FalseCheck that it listens on 0.0.0.0 or :: and not on 127.0.0.1, then open its port: Open a Port for Your Application on Windows Server.
A program listens that you do not knowLook where it runs from (step 1) and who logged in to the server: Who Logged In to Your Windows Server? Check Remote Desktop Logins and Failed Attempts.

Good to Know

  • All rules in a window: press Windows key + R, type wf.msc and open Inbound Rules. A green tick marks a rule that is switched on.
  • UDP has no connections to list. Get-NetUDPEndpoint shows the UDP ports that programs use.
  • Is the firewall on? Get-NetFirewallProfile -PolicyStore ActiveStore | Select-Object Name, Enabled, DefaultInboundAction should answer True and Block in every line.
  • First steps on a new server: Windows Server: Quick Start Guide.
Was this answer helpful? 0 Users Found This Useful (0 Votes)