Docs · Networking

Open ports on Windows Server

Allow inbound traffic through Windows Defender Firewall with PowerShell or the GUI.

Windows · 4 min read

Windows Server blocks most inbound traffic by default. Remote Desktop (port 3389) is allowed so you can log in; anything else needs a rule.

With PowerShell

Open PowerShell as Administrator and create an inbound rule. This one allows a single TCP port:

New-NetFirewallRule -DisplayName "Web (HTTP)" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow

More examples:

# Several TCP ports in one rule
New-NetFirewallRule -DisplayName "Web" -Direction Inbound -Protocol TCP -LocalPort 80,443 -Action Allow

# A UDP port
New-NetFirewallRule -DisplayName "Game server" -Direction Inbound -Protocol UDP -LocalPort 27015 -Action Allow

# A range of ports
New-NetFirewallRule -DisplayName "App range" -Direction Inbound -Protocol TCP -LocalPort 30000-30100 -Action Allow

List and remove your rules:

Get-NetFirewallRule -DisplayName "Web*" | Format-Table DisplayName, Enabled, Direction, Action
Remove-NetFirewallRule -DisplayName "Web (HTTP)"

With the GUI

  1. Open Windows Defender Firewall with Advanced Security (search for wf.msc).
  2. Select Inbound Rules, then New Rule in the right-hand panel.
  3. Choose Port, then TCP or UDP, and enter the port number or range.
  4. Choose Allow the connection.
  5. Leave Domain, Private and Public ticked.
  6. Give the rule a name you will recognise later, and finish.

Check the application is listening

Get-NetTCPConnection -State Listen | Where-Object LocalPort -eq 80

If nothing is listed, the application is not running or is listening on a different port.

Do not remove the Remote Desktop rule unless you have another way in.