Security

How to Turn On Firewall in Windows 11 and 10 (Defender Firewall)

To turn on firewall protection in Windows 10 and 11, open the Windows Security app, choose Firewall & network protection, select your network profile and switch Microsoft Defender Firewall to On. From an elevated PowerShell window, the same result comes from Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True.

The Windows firewall is called Microsoft Defender Firewall in the Windows Security app. Older documentation and the command-line tools still call it Windows Firewall or Windows Defender Firewall. It is all the same feature.

Turn on the firewall in the Windows Security app

This is the method Microsoft documents for Windows 11 and Windows 10, and it uses the same wording on both.

  1. Open the Windows Security app and select Firewall & network protection. You can also paste windowsdefender://network/ into the Run box (Win+R) to jump straight there.
  2. Select the network profile you want to change: Domain network, Private network or Public network. Windows shows which network you are currently connected to.
  3. Under Microsoft Defender Firewall, switch the setting to On.

Repeat for each profile that shows Off. A profile is a separate set of firewall settings that Windows applies depending on the type of network. A laptop that is fine on your home (Private) network can still have the Public profile switched off, and you would only notice in a café.

Turn on the firewall with PowerShell

Open PowerShell as administrator (right-click Start, then choose Terminal (Admin) or Windows PowerShell (Admin)) and run:

Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True

Microsoft's example for this cmdlet describes it as enabling the Windows Firewall on the local computer. -Profile is an alias of -Name, and it accepts Domain, Public and Private, separated by commas. The -Enabled parameter takes True or False when you manage a local computer. To change a single profile, list only that one:

Set-NetFirewallProfile -Profile Public -Enabled True

The cmdlet prints nothing on success unless you add -PassThru. To read the state back, use Get-NetFirewallProfile, which is listed in Microsoft's related links for the cmdlet:

Get-NetFirewallProfile | Select-Object Name, Enabled

Example output on a machine where all three profiles are on:

Name    Enabled
----    -------
Domain     True
Private    True
Public     True

Turn on the firewall from Command Prompt

In an elevated Command Prompt, netsh does the same job for all profiles at once:

netsh.exe advfirewall set allprofiles state on

Microsoft's command-line guide lists this next to the PowerShell command as the way to enable Windows Firewall on a local device. It also gives a reason to do it even if the firewall already looks fine: the guide says that if you find the rules you create are not enforced, you might need to enable Windows Firewall.

What the firewall does once it is on

Microsoft's documentation says Windows Firewall drops traffic that does not correspond to allowed unsolicited traffic, or traffic sent in response to a request by the device. In practice, the default for a computer is to block inbound connections that do not match a rule and to allow outbound connections that do not match a rule. These are the documented defaults of -DefaultInboundAction (Block) and -DefaultOutboundAction (Allow) when you manage a computer.

For the general idea of what a firewall is and how stateful filtering works, see What Is a Firewall?. This article only covers switching the Windows one on.

If the switch is greyed out or turns itself off

There is no single cause, so work through these in order.

  • The device is managed. Microsoft states that if an organization manages your device, policies may prevent you from changing the firewall configuration. A work or school laptop falls into this group. Ask your administrator. Group Policy has its own setting for this, Windows Firewall: Protect all network connections, under Computer Configuration, Administrative Templates, Network, Network Connections, Windows Firewall.
  • You are not elevated. The PowerShell and netsh commands change system-wide settings, so run them from an administrator window.
  • You are looking at the wrong profile. The Windows Security app shows the profile of the network you are connected to. Select each of the three profiles in turn, or run Get-NetFirewallProfile to see all of them in one table.
  • The firewall service was stopped. Microsoft says the Windows Defender Firewall service (service name MpsSvc) should not be stopped, because that is not supported and can cause problems. Those problems include a Start menu that stops working, modern apps that fail to install or update, and failed phone activation of Windows. Turning the profiles on is the supported route. If you stopped the service yourself while troubleshooting, start it again from the Services snap-in (services.msc) before turning the profiles on.

Allow one app instead of turning the firewall off

The usual reason people look for the off switch is a program that cannot connect. Microsoft's guidance is to allow that app through the firewall instead. The firewall then keeps protecting everything else.

If you need a rule from the command line, the same Microsoft guide shows the pattern. This example allows inbound traffic for one program, limited to the local subnet. The program path here is a placeholder, so replace it with your own:

New-NetFirewallRule -DisplayName "Allow Inbound MyApp" -Direction Inbound -Program "C:\Apps\MyApp\myapp.exe" -RemoteAddress LocalSubnet -Action Allow

The LocalSubnet keyword scopes the rule to your own network instead of the whole internet. The rule takes effect immediately.

The Windows Security app also has a Blocks all incoming connections checkbox. It blocks everything, including apps you have allowed, so it can stop some apps from working. Leave it unchecked unless you want that stricter behaviour on an untrusted network.

If it still fails

Run Get-NetFirewallProfile | Select-Object Name, Enabled immediately after turning the profiles on. If a profile flips back to False within minutes, something else is setting it, most likely a policy applied by an organization or a management tool. In that case the change has to be made where the policy comes from, because a local setting will keep being overwritten.

Frequently asked questions

Is the Windows firewall on by default?
Yes. Microsoft's documentation lists the default for the Enabled setting as True when managing a computer, so all three profiles (Domain, Private and Public) are on unless someone or something turned them off. Check the Windows Security app to see the current state for the network you are connected to.
Should I turn the firewall off to make a program work?
Usually not. Microsoft's Windows Security page suggests allowing the specific app through the firewall instead of turning the firewall off, because turning it off could make your device more vulnerable to unauthorized access.
Do I need to start the Windows Defender Firewall service?
The service (display name Windows Defender Firewall, service name MpsSvc) should keep running. Microsoft says the supported way to disable the firewall is to turn off the profiles and leave the service running, and that stopping the service is not supported and can cause problems such as a broken Start menu.
Why can't I change the firewall setting on a work laptop?
If an organization manages the device, its policies can prevent you from changing the firewall configuration. Microsoft's guidance is to contact your administrator.

Sources