Windows Firewall: Configure and Test Inbound and Outbound Rules
Windows Defender Firewall filters traffic per network profile (Domain, Private, Public). By default it blocks unsolicited inbound connections and allows outbound ones. To open a port, create an inbound allow rule with New-NetFirewallRule in an elevated PowerShell window or with netsh advfirewall firewall add rule. To stop an application reaching the internet, create an outbound block rule for its program path.