How to Open the Windows Firewall on Your Windows Server
For services such as game or web servers to be reachable from the outside, you have to open the required ports in the Windows Firewall. This guide shows you both ways — via the graphical interface and via PowerShell.
Note
You first need to be connected to your Windows Server to perform the following steps.
Via the graphical interface
Open the firewall
PressWindows + R, typewf.mscand confirm withEnter. The Windows Defender Firewall with Advanced Security opens.Create a new inbound rule
Click Inbound Rules on the left and then New Rule… on the right.Choose the rule type
Select Port and click Next.Specify protocol and port
Select TCP or UDP and enter the desired port under Specific local ports (e.g.25565). Click Next.Tip
Separate multiple ports with commas (
25565,25566), ranges with a hyphen (27015-27020). If your service needs both TCP and UDP, create a separate rule for each protocol.Allow the connection
Select Allow the connection and click Next.Select the profiles
Leave all profiles (Domain, Private, Public) enabled and click Next.Name the rule
Give it a meaningful name (e.g.Minecraft Server) and click Finish.
Via PowerShell
Alternatively, you can open a port directly via PowerShell — which is often faster.
Open PowerShell as administrator
Right-click the Start menu and select Windows PowerShell (Admin) or Terminal (Admin).Create the rule
Run the following command and adjust the name, port and protocol:powershellNew-NetFirewallRule -DisplayName "Minecraft Server" -Direction Inbound -LocalPort 25565 -Protocol TCP -Action AllowNew-NetFirewallRule -DisplayName "Minecraft Server" -Direction Inbound -LocalPort 25565 -Protocol TCP -Action AllowFor a UDP port, replace
TCPwithUDP.
Warning
Only open ports that are actually needed. Every open port increases the attack surface of your server.