Skip to content

Check Open Ports on Your VPS with nmap

Published:

After setting up a VPS, I wanted to confirm that only the ports I meant to expose were reachable from the internet. The quickest way is to scan it from outside with nmap.

What is nmap?

nmap is a command-line network scanner. You give it a host and a list of ports, and it reports the state of each one. Run it from your laptop, not from the server, so you see what the internet sees.

Install it with Homebrew:

brew install nmap

Scan the ports

nmap -Pn -p 22,80,443,6001,6002,8000,8080 <your-vps-ip>

Reading the result

22/tcp    open
80/tcp    open
443/tcp   open
6001/tcp  filtered
6002/tcp  filtered
8000/tcp  filtered
8080/tcp  filtered

For a typical web server, this is what I want. SSH (22), HTTP (80) and HTTPS (443) are open, and internal ports like 6001, 6002, 8000 and 8080 are filtered by the firewall.

If an internal port shows up as open, fix the firewall rule before anything else.

Scan codebase with deepsec
mkdir Is a Lock