Prerequisites
Before checking open ports, make sure you have:
- SSH access to your VPS
- Root or sudo privileges (for full port listing)
Method 1: Using netstat
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
Install net-tools if needed:
apt install net-tools -y
Show all listening ports:
netstat -tulpn
Output example:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1234/sshd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5678/nginx
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 5678/nginx
Options explained:
- -t - TCP ports
- -u - UDP ports
- -l - Listening ports only
- -p - Show program name/PID
- -n - Numeric (no DNS resolution)
Method 2: Using ss (Modern Replacement)
Show all listening ports:
ss -tulpn
Show TCP listening ports:
ss -tln
Show UDP listening ports:
ss -uln
Method 3: Using lsof
Install lsof:
apt install lsof -y
Show all listening ports:
lsof -i -P -n | grep LISTEN
Check specific port:
lsof -i :80
Method 4: Using nmap (External Scan)
Install nmap:
apt install nmap -y
Scan localhost:
nmap localhost
Scan specific ports:
nmap -p 1-1000 localhost
Method 5: Check Specific Port
netstat -tulpn | grep :80
Check if port is open using nc:
nc -zv localhost 80
Understanding Port States
- LISTEN - Port is open and accepting connections
- ESTABLISHED - Active connection
- CLOSE_WAIT - Connection closing
- TIME_WAIT - Connection closed but waiting
✅ You can now check open ports on your Hostxpeed VPS.