How to Open Ports on Windows 11 (Firewall, PowerShell and Router)

To open a port on Windows 11, press Windows + R, type wf.msc and press Enter, then go to Inbound Rules > New Rule > Port. Pick TCP or UDP, type the port number, choose Allow the connection, select the network profiles, and give the rule a name. The port is open as soon as you click Finish. No restart is needed.

That rule only lets traffic through the Windows firewall. If the connection comes from the internet rather than from another device in your home, your router also has to forward the port to your PC. This guide covers both parts, plus the PowerShell and Command Prompt versions of the same rule, how to check that the port really works, and how to close it again. The steps apply to Windows 11 Home and Pro. You need an administrator account.

On this page:

What “opening a port” actually does

A port is a numbered doorway that a program uses for network traffic. A web server listens on port 80 or 443, Remote Desktop listens on 3389, and a Minecraft Java server listens on 25565. Each port uses a protocol: TCP for most apps, UDP for things like voice chat, game traffic and DNS. Some apps need both.

The Windows firewall blocks unsolicited incoming connections by default. Opening a port means creating an inbound allow rule for a port number and protocol. Three things have to line up before another device can connect:

Advertisements
  1. The app is running and listening on that port. A firewall rule does not start anything; if nothing is listening, the port still looks closed.
  2. Windows allows it. That is the firewall rule this guide creates.
  3. The router forwards it to your PC. This only matters for connections from outside your home network.

If any one of those is missing, the connection fails, so it helps to check them in that order when something does not work.

Before you start: find the port, protocol and profile

  • Port number and protocol. Look in the app’s documentation, its settings screen, or its server config file. Write down whether it says TCP, UDP or both. Guessing TCP is a common reason a game or voice server still fails.
  • Port or app rule. If you know which program needs access, Microsoft notes that allowing an app through the firewall is generally safer than opening a port, because the app’s ports are only open while it needs them. A port rule stays open until you remove it. Use a port rule when the app’s instructions tell you to, or when the software runs as a service with no obvious program file.
  • Network profile. Windows treats each network as Public or Private (or Domain on a work network). New networks are set to Public by default. A rule only applies on the profiles you tick, so check yours in Settings > Network & internet > Wi-Fi (or Ethernet), select your network, and look at Network profile type. Your home network is usually best set to Private.
  • Admin rights. Creating firewall rules needs an administrator account. On a work or school PC, firewall rules may be controlled by your IT department, and your local rule may be ignored.

Open a port with Windows Defender Firewall

This is the standard method and the one most people need. The console is called Windows Defender Firewall with Advanced Security. Microsoft’s newer documentation shortens the name to Windows Firewall, but the screens are the same.

  1. Open the advanced firewall console. Press Windows + R, type wf.msc, and press Enter. You can also open the Windows Security app, select Firewall & network protection, and click Advanced settings. Click Yes if Windows asks for permission.
  2. Start a new inbound rule. In the left pane, click Inbound Rules. In the right-hand Actions pane, click New Rule. The New Inbound Rule Wizard opens.
Windows Defender Firewall with Advanced Security with Inbound Rules selected and New Rule highlighted in the Actions pane
Select Inbound Rules, then New Rule under Actions. This recreated console uses illustrative rules; no port or firewall setting was changed.
  1. Choose the Port rule type. Select Port and click Next. (Choose Program instead if you want an app-based rule; the rest of the wizard is almost the same.)
  2. Pick the protocol and port. Select TCP or UDP. Then select Specific local ports and type the port. For several ports, separate them with commas (25565,25575). For a range, use a hyphen (27015-27030). Click Next. Do not choose All local ports, which opens every port for that protocol.
New Inbound Rule Wizard Protocol and Ports page with TCP selected and port 25565 entered in Specific local ports
For this TCP example, enter 25565 under Specific local ports. This recreated wizard is illustrative and does not open a port.
  1. Allow the connection. Leave Allow the connection selected and click Next. The secure-connection option only works with IPsec, which home networks rarely use.
  2. Select the profiles. Tick the profiles where the rule should apply. For a home server or game, Private alone is the careful choice, as long as your home network is set to Private. Only tick Public if you really need the port open on hotel, café or other untrusted networks. Click Next.
New Inbound Rule Wizard Profile page with only the Private profile checked
This example applies the rule to Private networks only, leaving Domain and Public clear. The recreated wizard does not change a real firewall rule.
  1. Name the rule. Type a name you will recognize later, such as Minecraft server TCP 25565. Including the app, protocol and port in the name makes cleanup easy. Add a description if you like, then click Finish.

The new rule appears at the top of the Inbound Rules list with a green check mark, which means it is enabled. If the app needs both TCP and UDP on the same port, run the wizard a second time and choose the other protocol; one port rule can only cover one protocol.

Do you need an outbound rule? Usually not. Windows allows outgoing connections by default, so outbound rules only matter if you (or a security tool) set the firewall to block outbound traffic. If you do need one, the wizard is the same, but you start from Outbound Rules.

Open a port with PowerShell or Command Prompt

The command line is faster if you set up the same rule on several PCs, or if you just prefer typing. Right-click the Start button and choose Terminal (Admin). Both commands below create the same kind of rule the wizard makes. See our guide on running apps as administrator in Windows 11 if the admin option is missing.

PowerShell uses New-NetFirewallRule. This example opens TCP port 25565 on Private networks only:

New-NetFirewallRule -DisplayName "Minecraft server TCP 25565" -Direction Inbound -Protocol TCP -LocalPort 25565 -Action Allow -Profile Private

Change TCP to UDP for a UDP rule. The -LocalPort value accepts a single port, a range such as 27015-27030, or a comma-separated list. If you leave out -Profile, the rule applies to every profile, including Public.

Command Prompt uses netsh, which Microsoft documents in its netsh advfirewall reference. The same rule looks like this:

netsh advfirewall firewall add rule name="Minecraft server TCP 25565" dir=in action=allow protocol=TCP localport=25565 profile=private

Both commands should finish with no error (PowerShell prints the rule’s details; netsh prints Ok.). If you see “Access is denied” or “The requested operation requires elevation,” the window is not running as administrator.

Forward the port on your router for internet access

Skip this section if only devices on your own Wi-Fi need to connect, such as a laptop reaching a desktop’s shared files or a media server. For friends connecting over the internet, the router has to pass the traffic to your PC, because every device on your network shares one public IP address.

  1. Find your PC’s local IP address. Go to Settings > Network & internet, click Properties for your Wi-Fi or Ethernet connection, and note the IPv4 address (often something like 192.168.1.25).
  2. Keep that address from changing. In your router’s settings, look for DHCP reservation, address reservation or static lease, and reserve the address for your PC. Otherwise the router may hand your PC a different address after a restart, and the forwarding rule will point at nothing.
  3. Create the port forwarding rule. Sign in to your router’s admin page (the address and menu names are printed on the router or in its manual). Look for Port Forwarding, Virtual Server or NAT. Enter the same port number, the same protocol, and your PC’s IPv4 address, then save.
  4. Keep the Windows rule in place. Forwarding gets the traffic to your PC; the firewall rule from earlier still has to let it in.

Some setups make forwarding impossible from your side. If your internet provider’s modem is also a router and you have your own router behind it (double NAT), you need to forward the port on both or put the provider’s box in bridge mode. Some providers use carrier-grade NAT, which means you have no public IP address of your own, and some block common ports such as 25 or 80. Your provider can tell you which applies.

Check that the port is actually open

First, confirm that the app is listening. Open Command Prompt and run this, replacing the number with your port:

netstat -ano | findstr :25565

A line containing LISTENING means the app is ready for TCP connections. UDP ports do not show a LISTENING state, but they still appear in the list while the app is running. If nothing comes back, start the app or check its port setting. The firewall cannot help until something is listening. To identify which program owns a listening port, or to list every open port at once, see checking open ports with netstat, PowerShell and Resource Monitor.

Next, test from another device on the same network. On a second Windows PC, open PowerShell and run Test-NetConnection with your PC’s local IP:

Test-NetConnection -ComputerName 192.168.1.25 -Port 25565
PowerShell output of Test-NetConnection showing TcpTestSucceeded True for port 25565
An illustrative Test-NetConnection result shows TcpTestSucceeded : True for the example TCP port. These private addresses and output are fictional; no network test was run.

TcpTestSucceeded : True means the firewall rule works. Running the test on the PC that hosts the app only proves the app is listening, because connections from a PC to itself are not filtered the same way as traffic from other devices. Test-NetConnection only checks TCP; for a UDP port, the real test is whether the app (for example, the game client) can connect.

To test from the internet, use a device that is not on your Wi-Fi, such as a phone on mobile data, and connect to your public IP address. If it works on your local network but not from outside, the problem is the router or your provider, not Windows.

If the port still looks closed

  • Wrong protocol. The rule says TCP but the app uses UDP, or it needs both. Open the rule’s Properties > Protocols and Ports tab to check.
  • Wrong profile. The rule is set to Private but your network is set to Public. Either change the network profile in Settings or tick the right box on the rule’s Advanced tab.
  • A block rule wins. In the Windows firewall, a block rule beats an allow rule for the same traffic, as Microsoft’s firewall rules documentation explains. When you dismiss or cancel the “Windows Security has blocked some features” prompt for an app, Windows can create block rules for it. Sort Inbound Rules by Action, look for red block icons with the app’s name, and disable or delete them.
  • Another firewall is in charge. Antivirus suites such as Norton, McAfee or Bitdefender often replace the Windows firewall with their own. If Windows Security > Firewall & network protection says another app manages the firewall, add the port in that program instead.
  • The PC’s IP changed. The router is forwarding to an old address. Recheck the IPv4 address and set up a DHCP reservation.
  • The rule is scoped too narrowly. If you limited the rule to certain remote addresses on the Scope tab, make sure the connecting device is included.

Some guides suggest turning the firewall off for a minute to see whether it is the cause. That works as a quick test, but only do it on a trusted home network, and turn it back on right away. If the connection still fails with the firewall off, the problem is the app, the router or your provider.

How to close a port again

Close any port you no longer use. In wf.msc, click Inbound Rules, find your rule by name, and right-click it:

  • Disable Rule closes the port but keeps the rule, so you can turn it back on later with Enable Rule.
  • Delete removes the rule completely.

From an admin terminal, the PowerShell equivalent is Remove-NetFirewallRule -DisplayName "Minecraft server TCP 25565" (or Disable-NetFirewallRule with the same name to keep it). In Command Prompt, use netsh advfirewall firewall delete rule name="Minecraft server TCP 25565". Remember to remove the matching forwarding rule on your router too.

Common ports people open

Always use the numbers from your app’s own documentation, since many apps let you change their port. These are the usual defaults:

ServicePortProtocol
Web server (HTTP / HTTPS)80 / 443TCP
Remote Desktop3389TCP
SSH22TCP
FTP (control connection)21TCP
Minecraft Java Edition server25565TCP
Minecraft Bedrock Edition server19132UDP

Remote Desktop is a special case. Windows already includes predefined Remote Desktop firewall rules, so check for them in Inbound Rules before adding your own, and turn the feature on in Settings > System > Remote Desktop (the PC you connect to needs Windows 11 Pro). Exposing port 3389 directly to the internet is risky, and a VPN is the safer way to reach your PC from outside. For an FTP server, our guide to creating an FTP server in Windows 11 covers the extra steps that service needs.

Questions about ports on Windows 11

Is opening a port dangerous?

It adds risk, because anything that can reach the port can talk to the app behind it. The risk depends on the app: a fully updated game server behind your router is a much smaller target than an old service open to the internet. Keep it small by opening only the ports you need, limiting the rule to the Private profile, restricting the Scope to known IP addresses when you can, and removing rules you no longer use.

How do I see which ports are already open?

In wf.msc, the Inbound Rules list shows everything Windows allows; to see only active ones, click Filter by State > Filter by Enabled in the Actions pane. To see which ports programs are actually listening on, run netstat -ano in Command Prompt and match the PID column to the Details tab in Task Manager.

Is opening a port the same as allowing a website through the firewall?

No. Websites use outgoing connections, which Windows allows by default. If a site is blocked, the cause is usually a different setting; see our guide on allowing a website through the Windows 11 firewall. To go the other way and cut an app off from the network, read how to block internet access to an app in Windows 11.

Once your rule works, give it a clear name and make a note of the port on your router as well. When you stop using the app, delete both so your PC is not left with doorways nobody is watching.

Advertisements