...
Skip to main content
Print

How to Open a Port in Windows Firewall

The fastest way to open a port in Windows Firewall is with PowerShell and the New-NetFirewallRule command. You can also do it via Windows Defender Firewall with Advanced Security. Only open the ports you really need, such as 80 and 443 for a web server.

Opening a port with PowerShell

Open PowerShell as administrator and run this command. In this example we open TCP port 8080:

New-NetFirewallRule -DisplayName 'Poort 8080' -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow

For a UDP port, replace TCP with UDP.

Opening a port via the control panel

  • Press Windows + R, type wf.msc and press Enter.
  • Click Inbound Rules and then New Rule.
  • Choose Port, enter the port number, choose Allow the connection and give the rule a name.

Checking and removing rules

Get-NetFirewallRule -DisplayName 'Poort 8080'
Remove-NetFirewallRule -DisplayName 'Poort 8080'

Opening a port for one IP address

If you want to make a port accessible only from your own IP address, add -RemoteAddress JOUW-IP to the command.

Related articles

Table of Contents