Hostxpeed
Login Get Started →
Getting Started

How to Close a Port on VPS

3 min read
19 views
Jun 10, 2026

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.

Was this article helpful?