Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

How to Open Ports on Windows Server (VPS or Dedicated Server)

Open a port in Windows Firewall on Windows Server step by step, limit it to certain addresses, test it from outside, and find out why it still seems closed.

3 min readBy Smita

Reviewed by the AmazingRDP technical team

Opening ports on Windows Server

Opening ports needs administrator rights. A Windows VPS gives you full admin access. See Windows VPS from $8.99

A program on your server that should be reachable from the internet, a game server, a website, a database for one office, needs its port opened in Windows Firewall. "Opening a port" means adding one inbound rule. It takes a minute in the graphical tool, and this page also covers the two things that are usually wrong when the port still seems closed.

What you need to know first

  • The port number the program listens on, for example 25565.
  • The protocol: TCP or UDP. The program's documentation says which; some need both.
  • Administrator rights. On a shared remote desktop you cannot change the firewall.

Open the port

  1. Press Win + R, type wf.msc, press Enter. Windows Defender Firewall with Advanced Security opens.
  2. Click Inbound Rules on the left, then New Rule on the right.
  3. Rule Type: choose Port. Next.
  4. Protocol and Ports: choose TCP or UDP, select Specific local ports, and type the number. Several ports are separated by commas, a range is written with a hyphen: 80, 443, 5000-5010. Next.
  5. Action: Allow the connection. Next.
  6. Profile: leave all three ticked on a server. Next.
  7. Name: something you will recognise in a year, such as "Game server 25565 TCP". Finish.

The rule works at once. If the program needs TCP and UDP, create a second rule for the other protocol.

You do not need an outbound rule

The earlier version of this page had you create the rule twice, inbound and outbound. That is unnecessary. Windows Firewall allows outgoing connections by default, and answers to an allowed incoming connection are always let through. One inbound rule is enough.

Limit who may connect

A port open to the whole internet is found by scanners within minutes. If only certain people need it, say so in the rule:

  1. Double-click the rule and open the Scope tab.
  2. Under Remote IP address, choose These IP addresses and add the addresses or ranges that may connect.

Do this for databases, management tools and anything with a login. Leave web and game ports open to all.

The same from PowerShell

New-NetFirewallRule -DisplayName "Game server 25565 TCP" -Direction Inbound -Protocol TCP -LocalPort 25565 -Action Allow
New-NetFirewallRule -DisplayName "SQL from office" -Direction Inbound -Protocol TCP -LocalPort 1433 -RemoteAddress 198.51.100.20 -Action Allow
Get-NetFirewallRule -DisplayName "Game server*" | Format-Table DisplayName, Enabled, Action
Remove-NetFirewallRule -DisplayName "Game server 25565 TCP"

More examples in enabling a port through PowerShell.

Test it

On the server, check that the program is really listening:

netstat -ano | findstr :25565

A line with LISTENING and the address 0.0.0.0 means it accepts connections from outside. 127.0.0.1 means it accepts them only from the server itself, and no firewall rule will change that; the setting is in the program.

From another computer:

Test-NetConnection 203.0.113.10 -Port 25565

TcpTestSucceeded : True means open. This test is for TCP; UDP ports are tested with the program itself.

Still closed?

CheckWhy
Is the program running and listening?The most common cause. An open port with nothing behind it tests as closed
Is it bound to 127.0.0.1?See above
TCP or UDP?A rule for the wrong protocol looks right and does nothing
Is there a block rule?A rule that blocks wins over a rule that allows
Does the provider have a firewall in front?Some control panels have their own; open the port there too
At home: is the port forwarded on the router?A server behind a home router needs a forwarding rule as well. A VPS or dedicated server has its public address directly
Does a security suite bring its own firewall?Then the rule belongs there

Ports you should think twice about

  • 3389 (Remote Desktop): already open on your server and constantly tested by bots. Use a long password and consider limiting it to your addresses: see securing RDP.
  • 445 and 135 to 139 (file sharing): never to the internet.
  • 1433, 3306, 5432 (databases): only for named addresses.

Close it again

In wf.msc, right-click the rule and choose Disable Rule or Delete. Remove rules for programs you no longer run; an old open port is a door nobody watches.

Related: turning the firewall off for a test, and why not to leave it off; on Linux, how open ports work in Ubuntu. Ports for a website are opened by the installation of IIS. A Windows VPS has the administrator rights this needs.

Questions

How do I open a port on Windows Server?

Run wf.msc, choose Inbound Rules, New Rule, Port, enter the protocol and number, and allow the connection.

Do I need an outbound rule as well?

No. Outgoing connections and replies are allowed by default. One inbound rule is enough.

How do I check whether a port is open?

From another computer run Test-NetConnection SERVER -Port NUMBER in PowerShell.

Why is the port still closed after adding the rule?

Usually no program is listening on it, it listens on 127.0.0.1 only, or a provider firewall is in front.