🔓 How to Open or Close Ports on a VPS
Port management is a key part of securing and controlling access to your VPS. Proper configuration ensures that users can connect to your site, FTP, RDP, or other services. In this article, we explain how to open and close ports on Linux and Windows servers and how to check if a port is open.
🛡 Why Port Management Matters
- 🔐 Prevent unauthorized access to server services;
- 📉 Reduce vulnerabilities and risks of DDoS attacks;
- ⚙ Control access to specific applications and protocols;
- 📶 Optimize traffic and reduce system load.
🐧 Open/Close Ports on Linux (UFW)
UFW (Uncomplicated Firewall) is one of the simplest tools to manage ports on Linux.
- 🔓 Open port 80 (HTTP):
sudo ufw allow 80
- 🔒 Close port 80:
sudo ufw deny 80
- 🗑 Delete rule:
sudo ufw delete allow 80
- 📜 Show rules:
sudo ufw status
- ⚙ Enable firewall:
sudo ufw enable
🪟 Manage Ports on Windows Server (Firewall)
To open or close ports in Windows Server:
- 🧭 Go to Control Panel → Windows Firewall;
- 🛠 Click Advanced Settings → Inbound Rules;
- ➕ Click “New Rule” and select Port;
- 📥 Enter the port number (e.g., 3389 for RDP);
- 🔘 Choose to allow or block the connection and save the rule.
🔍 How to Check Port Availability
- 🧪 From local PC:
telnet IP PORT
ornc -zv IP PORT
- 🌐 Online tool: our port scanner
- 📋 On the server:
sudo netstat -tulpn
orss -tuln
📌 Bit.Hosting Recommendations
- 🔁 Only open necessary ports — keep others closed;
- 📋 Use IP whitelisting for sensitive services;
- 🔄 Regularly check open ports using
ufw status
or your VM panel; - 📊 Use Fail2Ban or similar tools to protect from brute-force attacks;
- 🧯 After any changes, always test your services for availability.
If you're unsure which ports to open or can't connect to your server — contact our support, and we'll help you configure everything correctly. 🔧