Since 2016 · 50,000+ customers · ★ 5.0 on Google Live chatWhatsAppTelegramOpen a ticket
Get started
Windows Server

How to Open a Port in Windows Firewall (Windows 10, 11 and Server)

How to open a port in Windows Firewall by 99RDP

When a game server, web server, database or remote tool on Windows cannot be reached from other computers, the usual reason is that Windows Defender Firewall is blocking its port. Opening the port adds an inbound rule that allows traffic on that port number. This guide shows how to open a TCP or UDP port with the firewall console, PowerShell and the command line, how to limit it to specific IPs, check that it works, and close it again.

Quick answerOpen PowerShell as administrator and run:

New-NetFirewallRule -DisplayName "Allow TCP 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow

Use -Protocol UDP for UDP ports, and -LocalPort 27015,27016 or -LocalPort 50000-50100 for several ports.

Before you start

  • Find out the port number and protocol (TCP, UDP or both) from the application's documentation.
  • Make sure the application is actually running and listening, or the port will still look closed.
  • Only open the ports you need. Every open port is a possible way in.
Steps to open a port in Windows Firewall: new inbound rule, port, TCP and number, allow, profiles, name
Open a port

Method 1: Windows Defender Firewall with Advanced Security

  1. Press Win + R, type wf.msc and press Enter.
  2. Click Inbound Rules in the left pane, then New Rule in the right pane.
  3. Choose Port and click Next.
  4. Select TCP or UDP, choose Specific local ports, and enter the port (for example 8080), several ports separated by commas, or a range such as 50000-50100. Click Next.
  5. Select Allow the connection. Click Next.
  6. Choose the profiles. On a server or VPS, leave Domain, Private and Public ticked. On a laptop, consider allowing only Private so the port is closed on public Wi-Fi.
  7. Name the rule clearly (for example "Web app TCP 8080") and click Finish.

If the application needs both TCP and UDP, create a second rule for the other protocol.

To restrict the port to certain IP addresses, open the new rule's Properties, go to the Scope tab, and add allowed addresses under Remote IP address.

PowerShell and netsh commands to open a port in Windows Firewall
Commands to open a port

Method 2: PowerShell

# One TCP port
New-NetFirewallRule -DisplayName "Allow TCP 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow

# UDP ports for a game server
New-NetFirewallRule -DisplayName "Game server UDP" -Direction Inbound -Protocol UDP -LocalPort 27015-27016 -Action Allow

# Only from one IP address (for example SQL Server from your office)
New-NetFirewallRule -DisplayName "SQL 1433 office" -Direction Inbound -Protocol TCP -LocalPort 1433 -RemoteAddress 198.51.100.25 -Action Allow

Method 3: Command Prompt (netsh)

netsh advfirewall firewall add rule name="Allow TCP 8080" dir=in action=allow protocol=TCP localport=8080
netsh advfirewall firewall add rule name="Allow UDP 9987" dir=in action=allow protocol=UDP localport=9987

Method 4: Allow a program instead of a port

For applications that use changing ports, allow the program itself:

New-NetFirewallRule -DisplayName "My server app" -Direction Inbound -Program "C:\Apps\server.exe" -Action Allow

Or use Control Panel → Windows Defender Firewall → Allow an app or feature through Windows Defender Firewall.

Troubleshooting when a port is still closed after adding a Windows Firewall rule
Port still closed?

Check that the port is open

On the Windows machine, confirm the application is listening:

netstat -ano | findstr :8080
Get-NetTCPConnection -LocalPort 8080 -State Listen

From another computer, test the connection:

Test-NetConnection 203.0.113.10 -Port 8080

TcpTestSucceeded : True means the port is reachable. For UDP, test with the application itself, because UDP has no handshake to check.

If the port is still closed

  • Nothing is listening: start the application, or check it is bound to the right IP and port.
  • Another firewall: on a VPS, open the port in the provider's firewall or security group too. At home, forward the port on your router to the PC's local IP.
  • Wrong profile: check which network profile is active (Get-NetConnectionProfile) and that the rule applies to it.
  • A block rule: block rules override allow rules; check for one covering the same port.
  • Third-party security software with its own firewall may also need a rule.

Close the port again

Remove-NetFirewallRule -DisplayName "Allow TCP 8080"
# or temporarily:
Disable-NetFirewallRule -DisplayName "Allow TCP 8080"

Common ports

ServicePort
HTTP / HTTPSTCP 80 / 443
Remote DesktopTCP and UDP 3389
Microsoft SQL ServerTCP 1433
MySQL / MariaDBTCP 3306
FTPTCP 21 plus passive range
SSH (OpenSSH Server)TCP 22

Frequently asked questions

How do I open a port in Windows 11?

Open wf.msc, create a new inbound Port rule, enter the port and protocol, and choose Allow the connection. Or run New-NetFirewallRule in PowerShell.

Do I need an outbound rule too?

Usually not. Windows Firewall allows outbound connections by default, so only inbound rules are needed for servers.

Is it safe to open ports?

It is safe to open ports for services you run and keep updated. Restrict sensitive ports such as databases and RDP to known IP addresses.

How do I check which ports are open on Windows?

Run netstat -ano or Get-NetTCPConnection -State Listen to see listening ports, and Get-NetFirewallRule -Enabled True -Direction Inbound to see firewall rules.

Minakshi, Server Administrator L1 at 99RDP
Written byMinakshiServer Administrator L1, 99RDP. Part of the team that runs our servers and answers support.
Keep reading

More Windows Server guides

All Windows Server guides

Need a server for this?

✓ Setup in minutes✓ Full admin access✓ 7-day refund on new services