Guide to Opening/Closing Ports on VPS (Linux& Windows)

VPTS Team Content has been moderated
Published date:17/4/2026 Update:11/8/2026 Views:153 Reviews: 5.0/5283reviews
VPTS on

While using a VPS, opening and closing ports is a necessary task for services to function and be accessed from the outside. However, if misconfigured, you might encounter...

While using a VPS, you may need toopen portso that websites, SSH, Remote Desktop, databases, APIs, or other applications can receive incoming connections.

Conversely, ports that are no longer in use should becloseto limit unnecessary connections and increase security for the VPS.

In this article, VPTS will provide detailed instructions on how toopen, close, and check ports on Linux and Windows VPS, applicable to popular operating systems such as Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS, and Windows Server.

1. What Is a Port on a VPS?

A port can simply be understood as a network communication endpoint used by services on a VPS to receive or send connections.

A single IP address can use multiple different ports. Each application typically listens on one or several specific ports.

2. Common Ports You Need to Know

ServicesPort
SSH (Linux)22
HTTP (Website)80
HTTPS443
FTP21
Remote Desktop – RDP3389
MySQL/MariaDB3306
PostgreSQL5432

3. Guide to opening/closing ports on Linux VPS

3.1. For Ubuntu (UFW)

Step 1: Check UFW status

sudo ufw status
Open Port on VPS
  • Returned result -> active->UFW is active.
  • Open a single port (Allow): for example, open port 80
  • The result will return as shown in the image below
Open Port on VPS

Step 2: Open a port

  • Example: need to open port80:

sudo ufw allow 80/tcp
  • If successful, UFW will add a rule allowing TCP connections to port 80.
  • You just need to replace80with the required port.

Step 3: Open HTTPS port 443

sudo ufw allow 80,443/tcp
  • Delete opened rule
sudo ufw delete allow 80

The result will return as shown in the image below

Open Port on VPS

Step 5: Check ports currently allowed by UFW

Run:

sudo ufw status numbered

The result will return as shown in the image below 

Open Port on VPS
  • If you want to delete by index number, run a command similar to the following
sudo ufw delete 5

No. are series of numbers 1, 2, 3, 4, 5, 6 as you see

Open Port on VPS

3.2. For FirewallD (CentOS 7+, RHEL, AlmaLinux)

Operating systems in the RHEL family typically usefirewalldto manage the firewall.

Step 1: Check FirewallD

Run:

sudo systemctl status firewalld

Step 2: Start FirewallD if it is not running

Run:

systemctl start firewalld systemctl enable firewalld
  • Then verify:
sudo systemctl status firewalld
  • Returned result active (running) ->ok
Open Port on VPS

Step 3: Open a port

Example: opening TCP port8080:

sudo firewall-cmd --add-port=8080/tcp --permanent sudo firewall-cmd --reload

If the result shows success, it is successful

Open Port on VPS

Step 4: Open ports 80 and 443

  • Run:
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --reload

All succeeded, linewarning: ALREADY_ENABLED: 80:tcp is not an error; it means that port 80 was already open beforehand.

Open Port on VPS

Step 5: Check list of opened ports

Run:

sudo firewall-cmd --list-ports

Displays all opened ports

Open Port on VPS

3.3. Open port with IPTables

Some legacy VPSs or Linux systems still manage firewalls directly using IPTables.

  • Example: opening TCP port8080:
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  • Check open ports
iptables -L -n

Displays all ports as shown in the image

Open Port on VPS

4. Guide to opening/closing ports on Windows VPS

4.1. Open port using Windows Firewall (popular method)

Step 1: Open firewall

  • Click search and typeWindows Defender Firewall with Advanced Security. Select Inbound Rules -> New Rule.
Open Port on VPS

Step 2: Select rule type

  • Select port and click Next
Open Port on VPS
  • Select TCP or UDP, enter the port to open
Open Port on VPS

Step 3: Allow connection

  • Select Allow the connection and click Next -> Next
Open Port on VPS
  • Name and finish
Open Port on VPS

Related articles to refer to below

4.2. Open port using CMD

  • Open port 80
netsh advfirewall firewall add rule name="Open Port 80" dir=in action=allow protocol=TCP localport=80
  • Open port 443
netsh advfirewall firewall add rule name="Open Port 443" dir=in action=allow protocol=TCP localport=443
  • Open Remote Desktop port (3389)
netsh advfirewall firewall add rule name="RDP Port 3389" dir=in action=allow protocol=TCP localport=3389

4.3. Disable (close) port on Windows

Method 1: Disable via GUI

  • Go toInbound Rules
  • Find the created rule
  • Right-click →DisableorDelete
Open Port on VPS

Method 2: Delete via CMD

sudo ufw allow 80
netsh advfirewall firewall delete rule name="Open Port 80"

5. Why can't I connect even though the VPS port has been opened?

  • Cloud firewall not yet opened
  • Application not running (not listening on port)
  • Firewall not enabled or misconfigured
  • Wrong port or wrong protocol
  • Incorrect domain or IP

At VPTS, we not only provide VPS but also support customers with:

  • Standard security firewall configuration
  • Open the correct port for each service (Web, Docker, AI, N8N…)
  • Performance optimization and quick troubleshooting

CONCLUSION

Through the company's guideVPTSopening and closing ports on a VPS (Linux&Windows) is an important step to ensure the system operates stably and securely. Just properly configure the firewall, open the necessary ports, and ensure the application is active to easily control access and optimize VPS performance effectively.

VPTS – Comprehensive Digital Infrastructure Solutions Provider

VPTS is a digital infrastructure solution provider in Vietnam, serving deployment, operation, and data storage needs for individuals, developers, and enterprises. The service ecosystem includesVietnam VPS, International VPS, VPS Anti DDoS, Hosting cPanel, dedicated server, Rack rental, Proxy IPv4/IPv6, S3 MinIOandCloud Storage.

Besides providing infrastructure resources, VPTS also focuses on assisting customers with deployment, configuration, and practical troubleshooting. Content on the VPTS Blog is drawn from common scenarios in operating VPS, servers, and online systems, helping readers understand root causes and apply clear solutions.

VPTS – Stable infrastructure, flexible solutions, and continuous partnership throughout operations.

VPTS Team Contact Information