Prerequisites
Before closing a port, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
- UFW firewall installed
⚠️ Do NOT close port 22 (SSH) unless you have alternative access method!
Method 1: Delete by Rule Number
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
List rules with numbers:
sudo ufw status numbered
Delete by number:
sudo ufw delete 3
Method 2: Delete by Port and Protocol
sudo ufw delete allow 8080/tcp
✅ Port has been closed. External connections to this port will now be blocked.