A practical guide to allowing trusted apps, programs, ports, services, and IP addresses through Windows Defender Firewall without opening more access than necessary.
A Windows Firewall exception is an allow rule that lets specific network traffic pass through Windows Defender Firewall. The exception can allow a particular app, a desktop program file, a Windows service, a port number, a protocol, or traffic from a trusted IP address.
In Windows 10 and Windows 11, firewall exceptions are usually created in one of two places: the simple Allow an app through firewall screen, or the advanced console called Windows Defender Firewall with Advanced Security. The advanced console gives you more control over direction, program path, protocol, port, profile, and remote address scope.
Allows a specific app or executable file through the firewall. Best for most desktop programs and Microsoft Store apps.
Allows traffic to a TCP or UDP port, such as 8080, 25565, or 3389. Useful for servers and network tools.
Allows traffic only from selected local network addresses, subnets, or trusted devices instead of the entire network.
You may need to add an exception when a trusted application must receive inbound connections or when another device cannot connect to a service running on your Windows PC.
Before changing firewall rules, identify exactly what must be allowed. This avoids creating an exception that is too broad or difficult to troubleshoot later.
| Question | Why It Matters | Example |
|---|---|---|
| Which program needs access? | A program-based rule is usually safer than a port-only rule. | C:\Program Files\MyApp\MyApp.exe |
| Inbound or outbound? | Most app-hosting problems require inbound rules. Outbound rules are used when outgoing traffic is restricted. | Inbound rule for a local server |
| Which network profile? | Private is usually safer for home or office LANs. Public should be limited. | Private only |
| Which protocol and port? | TCP and UDP are separate. Some apps require both. | TCP 8080 or UDP 27015 |
| Which devices may connect? | Remote address scope can limit the rule to trusted IP addresses. | 192.168.1.0/24 |
Private is normally the correct profile for a trusted home or office network. Public is used for untrusted networks such as hotels, airports, cafés, and shared Wi-Fi. If you are not sure which profile your network uses, open Settings → Network & Internet and check the active connection properties.
This is the easiest method when you want to add a firewall exception for a regular desktop program or a listed Microsoft Store app.
Win + R, type control firewall.cpl, and press Enter..exe file, and click Add.The advanced firewall console is better when you need a named rule, a precise program path, selected network profiles, or remote IP restrictions.
Win + R, type wf.msc, and press Enter.Good firewall rule names:
Allow Plex Media Server - Private LAN
Allow TCP 8080 - Local Web Test Server
Allow MyApp.exe Inbound - Accounting Network
After creating the rule, double-click it to review the Programs and Services, Protocols and Ports, Scope, and Advanced tabs. These tabs control what the exception allows and where it applies.
A port exception is useful when you know the exact TCP or UDP port required by a server, game, device tool, or development environment. Use a program exception when possible; use a port exception when the app documentation specifically requires a port.
Win + R, type wf.msc, and press Enter.8080. You can also enter a range such as 5000-5010.| Example Rule | Protocol | Port | Recommended Scope |
|---|---|---|---|
| Local web test server | TCP | 8080 |
Private profile, local subnet only |
| Minecraft Java server | TCP | 25565 |
Private profile or trusted remote addresses |
| Remote Desktop | TCP/UDP | 3389 |
VPN or trusted IP addresses only |
| File sharing / SMB | TCP | 445 |
Private LAN only; do not expose to internet |
PowerShell is useful for administrators, repeatable setup, scripts, and remote support. Open Terminal (Admin) or Windows PowerShell (Admin) before running the commands below.
PowerShellNew-NetFirewallRule `
-DisplayName "Allow MyApp Inbound - Private" `
-Direction Inbound `
-Program "C:\Program Files\MyApp\MyApp.exe" `
-Action Allow `
-Profile Private
PowerShellNew-NetFirewallRule `
-DisplayName "Allow TCP 8080 - Local Web Server" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 8080 `
-Action Allow `
-Profile Private
PowerShellNew-NetFirewallRule `
-DisplayName "Allow UDP 27015 - Game Server" `
-Direction Inbound `
-Protocol UDP `
-LocalPort 27015 `
-Action Allow `
-Profile Private
PowerShellNew-NetFirewallRule `
-DisplayName "Allow TCP 8080 from LAN only" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 8080 `
-RemoteAddress 192.168.1.0/24 `
-Action Allow `
-Profile Private
Replace the program path, display name, port, protocol, profile, and remote address with the values required by your app or network.
Command Prompt can create firewall exceptions with netsh advfirewall. This is useful on older scripts or systems where PowerShell is not preferred.
Command Promptnetsh advfirewall firewall add rule name="Allow MyApp Inbound - Private" dir=in action=allow program="C:\Program Files\MyApp\MyApp.exe" profile=private enable=yes
Command Promptnetsh advfirewall firewall add rule name="Allow TCP 8080 - Local Web Server" dir=in action=allow protocol=TCP localport=8080 profile=private enable=yes
Command Promptnetsh advfirewall firewall add rule name="Allow UDP 27015 - Game Server" dir=in action=allow protocol=UDP localport=27015 profile=private enable=yes
The safest firewall exception is the narrowest exception that still allows the app to work. After creating a rule in wf.msc, you can restrict it further.
wf.msc.wf.msc.192.168.1.50 or 192.168.1.0/24.Review custom firewall exceptions periodically. Old test rules, duplicate rules, or rules for removed applications can create unnecessary exposure and make troubleshooting harder.
| Task | GUI Method | PowerShell Command |
|---|---|---|
| Disable a rule | Open wf.msc, right-click the rule, select Disable Rule. |
Disable-NetFirewallRule -DisplayName "Rule Name" |
| Enable a rule | Right-click the rule and select Enable Rule. | Enable-NetFirewallRule -DisplayName "Rule Name" |
| Remove a rule | Right-click the rule and select Delete. | Remove-NetFirewallRule -DisplayName "Rule Name" |
| View matching rules | Use the search/filter options in Inbound Rules. | Get-NetFirewallRule -DisplayName "*MyApp*" |
Command Promptnetsh advfirewall firewall delete rule name="Allow TCP 8080 - Local Web Server"
If the app is still blocked after you add an exception, check the rule direction, profile, program path, protocol, port, and whether the application is actually listening for connections.
| Problem | What to Check | Fix |
|---|---|---|
| Wrong network profile | The rule is allowed for Private, but Windows marks the network as Public. | Change the active network to Private if it is trusted, or add the correct profile to the rule. |
| Wrong rule direction | Inbound vs outbound rule. | Create an inbound rule when other devices need to connect to this PC. |
| Program path changed | The app was updated or moved to another folder. | Edit the rule or create a new rule with the current .exe path. |
| No service is listening | netstat -ano | findstr :PORT |
Start the app or service that should accept connections. |
| Wrong protocol | The app requires UDP, but only TCP was allowed, or the opposite. | Create the correct TCP or UDP rule. Some apps require both. |
| Router blocks access from internet | Port forwarding, WAN IP, CGNAT, and router firewall rules. | Configure router port forwarding only when external access is required and safe. |
| Third-party firewall is active | Security suites may replace or add another firewall layer. | Add the exception in the third-party firewall or test with it temporarily disabled. |
Command Promptnetstat -ano | findstr LISTENING
netstat -ano | findstr :8080
PowerShellGet-NetTCPConnection -State Listen
Test-NetConnection 192.168.1.50 -Port 8080
wf.msc, find the rule under Inbound Rules or Outbound Rules, then disable or delete it. In PowerShell, use Disable-NetFirewallRule or Remove-NetFirewallRule.For most users, the safest method is to allow a specific app through Windows Firewall and enable it only on the Private profile. For more control, use wf.msc to create a named inbound rule, select the exact program or port, and limit the scope to trusted IP addresses.
Add only the firewall exceptions you truly need, use descriptive rule names, avoid the Public profile unless required, and remove old rules after testing. A narrow rule for a trusted app or trusted IP range is much safer than a broad rule that allows every device to connect.