Contents
- 1 How To Allow an App through Windows Defender Firewall via Windows Security Alert
- 2 How to Allow a Program Through Windows Defender Firewall in Windows Firewall Settings
- 3 How to Remove Allowed App in Windows Firewall Settings
- 4 How to Allow or Block a Program from Accessing the Internet via Command Prompt
- 5 How to Remove an Allowed App from Windows Defender Firewall with Command Prompt
- 6 How to Allow or Block a Program in Windows Firewall via PowerShell
- 7 How to Remove Allowed Windows Firewall App in PowerShell
- 8 How to Open or Close a Port in Windows Firewall
- 9 How to Perform a Network Reset
Windows Firewall, now known as Windows Defender Firewall, is a useful tool for a number of reasons. Though you can use it for several purposes, today weâre going to show you how to block a program from accessing the internet in Windows Firewall. Weâll also show you how to allow an app through Firewall if its connectivity isnât working.
Allow or block internet access of programs and apps
Knowing how to block programs in Firewall is useful for several reasons. You may want to prevent it from receiving updates, stop it from sending data back to a remote server, or simply want to know how it functions offline.
Conversely, allowing a program through Windows Firewall can help it to function better online. This is especially true if anybody is connecting to your app from the outside world (such as when youâre hosting a game or media server). If you get the âyour internet access is blocked â security or firewall settings might be blocking the connectionâ error, this is also useful, as it lets you return a blocked app to normal functioning.
The most user-friendly way to allow block an app in Firewall is, of course, via the Windows Defender Firewall app or security alert. However, weâll also be showing you how to achieve the same effect via the command-line for pro users or those without a GUI.
How To Allow an App through Windows Defender Firewall via Windows Security Alert
The most efficient way to allow a program through a Firewall is to simply tick the right option when you first launch it. Most apps that need firewall access will ask you whether you want to allow access via a Windows Security Alert prompt. Hereâs what you need to do when you see it:
How to Allow a Program Through Windows Defender Firewall in Windows Firewall Settings
If you missed the Security Alert app shortly after you launched the app, you can stop Windows Firewall from blocking internet connectivity by adding it to your allowed list manually. This only takes a minute or so and is very simple through the Control Panel.
- Press the search icon and open Control Panel
Press the search button on your taskbar, type âControl Panelâ, and click the top result.
- Type âWindows Firewallâ in the Control Panel search and choose âWindows Defender Firewallâ in the main list
Â
- Click âAllow an app or feature through Windows Defender Firewallâ
This option will be the sidebar on the left.
- Press âChange settingsâ in the âAllowed appsâ window
Allowing a program in Firewall requires you to provide administrator access.
- Press âAllow another appâ¦â at the bottom of the window
Â
- Next to the âPathâ box, press âBrowseâ¦â
Â
- Browse to your applications .exe, click it, and press âOpenâ
Â
- Click the âNetwork typesâ¦â button in the bottom-left
Â
- Tick âPrivateâ and/or âPublicâ networks and press âOKâ
Â
- Press âAddâ to allow the app through Firewall
Â
- Find the program in your âAllowed appsâ list and make sure itâs ticked
Press âOKâ when youâre done to close the window.
How to Remove Allowed App in Windows Firewall Settings
If you previously allowed an app through Firewall but now regret it, you can rectify it by removing it in Windows Firewall settings. Thankfully, this is pretty easy to do:
- Open Control Panel
Press the search icon and type âControl Panelâ, then click the top result.
- Search Control Panel for Windows Firewall and select it from the list
Â
- Press âAllow an app or featureâ¦â in the sidebar
Â
- Click âChange settingsâ and provide admin privileges
Â
- Find the program in your allowed apps list, click it, and press âRemoveâ
Â
- Press âYesâ to the prompt
Thatâs it, the app is no longer allowed through your firewall. Doing this will not automatically block internet access to a program, but will modify how it interacts with the outside world. Depending on its function, this may stop it from working properly.
- Press âOKâ in the âAllowed appsâ window
Â
How to Allow or Block a Program from Accessing the Internet via Command Prompt
If you prefer the command-line, you can change Windows Firewall rules through Command Prompt instead. This is typically faster than jumping through the settings menu if you have the commands memorized. Hereâs what you need to do:
- Open Command Prompt as an admin
Press the search icon on your taskbar and type âCommand Promptâ, then right-click it and press âRun as administratorâ.Â
- Use the netsh command to allow a program through Windows Firewall in Command Prompt
Hereâs an example of what youâd type to allow an app through the Firewall in Windows 11 or 10:
netsh advfirewall add rule name="Firefox" dir=in action=allow program="C:/Program Files/Mozilla Firefox/firefox.exe" enable=yes
You should change in quotation marks to fit the specific program youâre trying to allow. After performing this change, you should no longer receive the âsecurity or firewall settings might be blocking the connectionâ error.
- Use netsh to block a program in Windows Firewall
If youâd rather block the program, the command is very similar to above. You just have to switchÂ
action=allow
 toÂaction=block
. Hereâs what the full command looks like:netsh advfirewall firewall add rule name="Firefox" dir=in action=block program="C:/Program Files/Mozilla Firefox/firefox.exe" enable=yes
Again, you should change everything thatâs in quotation marks to suit the app youâre trying to block internet access to in Firewall.
How to Remove an Allowed App from Windows Defender Firewall with Command Prompt
You can also use Command Prompt to remove apps that youâve previously allowed in your Firewall. Hereâs how:
- Open Command Prompt as an administrator
Press the search icon on your taskbar and type âCommand Promptâ, then right-click the top result and choose âRun as administratorâ.
- Run the show rule command to export a list of your firewall entries
To do so, simply paste the following into your Command Prompt and press Enter:
netsh advfirewall firewall show rule name=all >"%UserProfile%/Desktop/WindowsFirewallRules.text"
- Open the âWindowsFirewallRules.txtâ file on your desktop and find your application
Youâll see the name of the rule you created next to the âRule Nameâ field. If youâre struggling to find your rule, you can press Ctrl + F to search.
- Use the netsh command to delete the firewall rule
Once you know the name of your firewall rule you can delete it by running the following command:
netsh advfirewall Delete rule name="yourfirewallrule"
Naturally, you should replace âyourfirewallruleâ with the name of your rule. After you receive the âDeleted x rule(s)â confirmation, you can close Command Prompt.
How to Allow or Block a Program in Windows Firewall via PowerShell
If you want to allow or block a program in Firewall using Microsoftâs more modern PowerShell tool, you can do so with the NetFirewallRule
 command. Hereâs how:
- Open Windows PowerShell as an admin
The easiest way to do this is to open the hidden Start menu by pressing âWindows + Xâ and then clicking âWindows PowerShell (Admin)â.
- Use NetFirewallRule to allow a program through the Firewall
If you want to allow an app, your command should look something like this:
New-NetFirewallRule -DisplayName "firewallrulename" -Direction Inbound -Program "C:/path/to/your/file.exe" -Action Allow
Replace âfirewallrulenameâ with whatever youâd like your rule to be called, and âC:/path/to/your/file.exeâ with the path to your programâs executable. Press Enter to run the command.
- Use NetFirewallRule to block a program in Windows Firewall
If you want to block an app, your command should look something like this:
New-NetFirewallRule -DisplayName "firewallrulename" -Direction Inbound -Program "C:/path/to/your/file.exe" -Action Block
Replace âfirewallrulenameâ with whatever youâd like your rule to be called, and âC:/path/to/your/file.exeâ with the path to your programâs executable. Press Enter to run the command.
How to Remove Allowed Windows Firewall App in PowerShell
If you previously added an app to the Firewall via PowerShell but now want to remove, it the process is relatively simple:
- Open PowerShell as an admin
The easiest way to do this is to open the hidden Start menu by pressing âWindows + Xâ and then clicking âWindows PowerShell (Admin)â.
- Export a list of your Firewall rules
Before you can stop allowing a program in Firewall you need to know its rule name. You can obtain this by exporting a list of all of your Firewall rules to your desktop. Just run the following command to do so:
Show-NetFirewallRule | Out-File "$env:userprofile/Desktop/WindowsFirewallRules.txt"
- Open âWindowsFirewallRules.txtâ from your desktop and find your rule name
The rule name will be in the column next to the âDisplayNameâ label. Note it down ready for the next command.
- Remove the rule with PowerShell
Now that you know the rule name, itâs a simple process of running the following command:
Remove-NetFirewallRule -DisplayName "YourRule"
Naturally you need to replace âYourRuleâ with the name of your actual rule.
How to Open or Close a Port in Windows Firewall
As well as allowing and blocking applications, Windows Defender Firewall lets you open and close specific ports. This may be useful if youâre trying to use SSH for example. You can check our how to open or close a port in Windows Firewall guide to learn how.
How to Perform a Network Reset
If youâre still experiencing connectivity issues after allowing an app through your Firewall, you can try performing a Windows Network reset. This will reset all of your settings to default and hopefully fix any strange behavior youâve been experiencing. It will, however, keep your Firewall rules.