Windows Defender Firewall controls which network traffic is allowed in and out of your system. This guide explains how to create inbound and outbound rules using the GUI and netsh.

Open the Advanced Firewall Console

Run wf.msc from the Run dialog to open the Windows Defender Firewall with Advanced Security console.

Create an Inbound Rule

Click Inbound Rules > New Rule. Choose Port, set TCP/UDP and the port number, then choose Allow or Block.

netsh advfirewall firewall add rule name="Block Port 8080" protocol=TCP dir=in localport=8080 action=block