Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Open or Close a Port in Windows Firewall

This guide shows how to let a program talk through Windows Firewall by opening a port, and how to close it again.

Firewall2 min read13 steps9 screenshots

What is a port?

A computer has thousands of numbered doors called ports. Each service uses its own door. For example, websites use port 80 and 443. Remote Desktop uses port 3389.

The Windows Firewall is a guard that keeps most doors shut. If you run a program that needs outside connections, such as a web server, you must open its door. This applies to a Windows VPS or a Windows computer. You need administrator rights.

Warning: Every open port is a possible way in. Open only what you need. Close it when you are done.

Open a port

  1. Click Start. Type Windows Defender Firewall with Advanced Security and open it.
    Screenshot: Click Start . Type Windows Defender Firewall with Advanced Security and open it.
    Screenshot: Click Start . Type Windows Defender Firewall with Advanced Security and open it.
  2. Click Inbound Rules on the left. Inbound means traffic coming in.
  3. Click New Rule on the right.
  4. Select Port and click Next.
  5. Choose TCP or UDP. Most services use TCP. The software's guide tells you which.
  6. Select Specific local ports. Type the number, for example 8080. Click Next.
  7. Select Allow the connection. Click Next.
  8. Tick the network types: Domain, Private, Public. For a server on the internet, Public is needed. Click Next.
  9. Type a name, like "Open port 8080". Click Finish.

The new rule appears in the list and starts working right away.

Close a port

  1. Open Inbound Rules again.
    Screenshot: Open Inbound Rules again.
    Screenshot: Open Inbound Rules again.
  2. Find your rule by name.
  3. Right-click it.
  4. Choose Disable Rule to pause it, or Delete to remove it.
    Screenshot: Choose Disable Rule to pause it, or Delete to remove it.

Do it with a command

Open PowerShell as administrator. To open port 8080:

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

This adds a rule that allows incoming TCP traffic on port 8080.

Screenshot: This adds a rule that allows incoming TCP traffic on port 8080.

To remove it:

Remove-NetFirewallRule -DisplayName "Open port 8080"

This deletes the rule with that name.

Test the port

From another computer, run:

Screenshot: From another computer, run:
Test-NetConnection -ComputerName YOUR_SERVER_IP -Port 8080

If it says TcpTestSucceeded : True, the port is open. The program must also be running. Some hosts have a second firewall outside your server. Ask Hostvento support if the port stays closed.

Tip: Instead of opening a port to everyone, limit it to a trusted IP address on the rule's Scope tab.

Need help? Open a support ticket.

Quick recap

  • A port is a numbered door for a service.
    Screenshot: A port is a numbered door for a service.
  • Add an Inbound Rule to open one.
  • Disable or delete the rule to close it.
    Screenshot: Disable or delete the rule to close it.
  • Open only the ports you need.
  • Test with Test-NetConnection.