Exceptions
To create a firewall exception to allow an app to communicate through the Windows Defender Firewall, open the Windows Defender Firewall applet from the Control Panel. Then select Allow an app or feature through Windows Defender Firewall.
You can specify exceptions based on an app or port number.
You can set an app to be allowed through the Firewall on a Private network but not allowed on a public network, or vice versa.
For more advanced exceptions, you can create a custom rule. Custom rules are found by clicking on the Advanced settings of the Windows Defender Firewall applet. This will list out inbound rules, outbound rules, connection security rules, and monitoring rules.
Note that there is an option in the Windows Firewall Customize Settings that will block all incoming connections, including those in the list of allowed apps. This would block all connections even if exceptions were made.
Configuration
Enabling/disabling Windows Firewall
In order to secure your system, your Windows firewall should always be on. However, there may be times when you’ll need to change or disable the firewall to troubleshoot.
Enabling or disabling the Windows firewall requires elevated privileges. Go to the Windows Defender Firewall applet in the Control Panel and there will be an option to turn the firewall on or off.
In the Windows Defender Firewall applet you can also customize the settings and notifications depending on what type of network you’re on. For example, you can turn off Windows Defender Firewall on a private network, but turn on Windows Defender Firewall when you’re on a public network. Alternatively, you can keep Windows Defender Firewall on for both public and private networks but you can set Windows Defender Firewall to notify you when it blocks an app on a private network, but not notify you when in blocks an app on a public network.