Windows Defender Firewall is a great feature in modern Windows versions. It was introduced in Windows XP and improved in Windows XP Service Pack 2. In Windows 10, it is part of the Windows Security app (formerly Windows Defender Security Center). Today, we will see how to open a port in Windows Firewall in Windows 10 for an app or a service.
Advertisеment
In Windows 10, Windows Firewall is based completely on the Windows Filtering Platform API and has IPsec integrated with it. This is true since Windows Vista where the firewall added outbound connection blocking and also comes with an advanced Control Panel called Windows Firewall with Advanced Security. It gives fine-grained control over configuring the firewall. The Windows Firewall supports multiple active profiles, co-existence with third-party firewalls, and rules based on port ranges and protocols.
You may have an app (e.g a local FTP server) which requires a port(s) to be open so other computers on your network can connect to it.
Before you open or close ports in the Windows Firewall, ensure that you are signed in as an administrator.
To open a port in Windows Firewall in Windows 10, do the following.
- Open Windows Security.
- Click on the icon Firewall & network protection.
- On the next page, click on the link Advanced settings.
- Click on Inbound Rules on the left.
- On the right, click on the New Rule link.
- Select Port as the rule type and click Next.
- Fill in the Specific local ports box. Type there the required port number or a range of ports. Set the required network protocol (TCP or UDP) and click Next.
- On the next page, select the option Allow the connection. Click Next.
- Select the Windows Firewall profile the new rule should apply to. E.g. leaving the Private profile enabled and disabling others will make your app available only on home networks.
- On the next page, provide some meaningful description for your firewall rule. Click on the Finish button.
Voila, you have opened the inbound port in Windows 10 Firewall.
The same can be done for an outbound port if it is required by your app. In Windows Firewall with Advanced Security, click on the Outbound Rules instead of Inbound Rules and follow the wizard.
Finally, to close the opened port, remove the rule or just disable it.
The change will take effect instantly.
There are a couple alternative methods you can use to open a port in Windows 10. Let's review them.
Open a port using netsh
Netsh is a console utility which allows changing a lot of network related parameters. Here are just a few examples of what you can do with netsh:
- Check supported WiFi speed of your Wireless adapter in Windows 10
- Backup and restore Wireless network profiles in Windows 10
- Filter wireless networks in Windows 10 to create a black list or white list
- Set up Windows 10 ad hoc wireless hotspot
To open a port using netsh, do the following.
- Open an elevated command prompt.
- Type the following command:
netsh advfirewall firewall add rule name="TCP Port 6624" dir=in action=allow protocol=TCP localport=6624
. Modify the appropriate values to match your app, e.g. the port number, the rule name, the protocol (TCP or UDP). - To delete the rule, execute the command as follows.
netsh advfirewall firewall delete rule name="TCP Port 6624" protocol=TCP localport=6624
.
Open a port using PowerShell
PowerShell is an advanced form of command prompt. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use .NET framework/C# in various scenarios. You can use it to open or close a port in Windows 10.
There is a special cmdlet New-NetFirewallRule that can be used to open or block a network port in Windows 10.
To open a port with PowerShell,
- Open an elevated PowerShell instance.
- Type the following command:
New-NetFirewallRule -DisplayName 'My port' -Profile 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 6624
That's it.
Articles of interest:
- Add Windows Firewall Context Menu in Windows 10
- How To Allow Or Block Apps In Windows Firewall in Windows 10
- How To Disable Windows Firewall in Windows 10
- Disable Firewall Notifications In Windows 10
- How to Backup and Restore Firewall Rules in Windows 10
- How to Reset Windows Firewall in Windows 10
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment