Nmap Port Scanning: A Practical Guide to Finding Open Services
Learn how Nmap port scanning works by running practical scans against a local machine and an authorized test target. Understand open, closed, and filtered ports, service detection, useful scan options, and how to turn Nmap output into actionable security information.

Nmap Port Scanning: A Practical Guide to Finding Open Services
Finding an open port is often the first useful clue when you're troubleshooting a network.
Nmap helps you discover hosts, examine ports, identify services, and understand how a system is exposed from your current network position.
Only scan systems you own or have explicit permission to test.
Start With a Real Question
Instead of memorizing Nmap commands, start with the question you need to answer.
| Question | Nmap feature |
|---|---|
| Is the host reachable? | Host discovery |
| Which ports are open? | Port scanning |
| What service is running? | Service detection |
| Is a specific port reachable? | -p |
| Can Nmap identify the OS? | -O |
| How do I save the result? | -oN or -oX |
Your First Scan
Scan your own machine:
nmap 127.0.0.1You may see output similar to:
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp closed httpsThe result gives you three useful pieces of information:
- PORT — the port and protocol
- STATE — what Nmap determined about the port
- SERVICE — the service associated with the port
What Does open Actually Mean?
An open port means that an application is listening and responding on that port.
For example:
22/tcp open sshThis does not mean the machine is vulnerable.
It means an SSH service is reachable.
The next security question is:
Is SSH supposed to be exposed here?
That distinction is important throughout network security.
Open, Closed, and Filtered
Open
22/tcp open sshAn application is listening.
Closed
8080/tcp closedThe host is reachable, but no application is listening on that port.
Filtered
443/tcp filteredNmap cannot determine the port state because filtering is preventing a clear response.
filtered does not necessarily mean that no service exists. It means Nmap cannot determine the state reliably from the available responses.
Scan Specific Ports
If you already know which ports matter, scan only those ports.
nmap -p 22,80,443 127.0.0.1For a range:
nmap -p 3000-3010 127.0.0.1This is particularly useful for developers.
Imagine your application uses:
Next.js → 3000
Node.js API → 4000
PostgreSQL → 5432You can check the expected ports:
nmap -p 3000,4000,5432 127.0.0.1Now Nmap becomes a debugging tool rather than simply a security tool.
Find Out What Is Running
Knowing that port 8080 is open is useful.
Knowing what is actually running there is better.
Use service detection:
nmap -sV -p 8080 127.0.0.1A result might look like:
PORT STATE SERVICE VERSION
8080/tcp open http Node.js ExpressThe exact result depends on the application and Nmap's detection capabilities.
Think of a Scan as an Investigation
The useful workflow is:
Target
↓
Discover
↓
Find ports
↓
Identify services
↓
Compare with expected architecture
↓
Investigate anything unexpectedA Developer Example
Suppose you start a Node.js API locally:
const express = require("express");
const app = express();
app.get("/health", (req, res) => {
res.json({ status: "ok" });
});
app.listen(4000, () => {
console.log("API running on port 4000");
});You expect port 4000 to be open.
Check it:
nmap -p 4000 127.0.0.1If the result is:
PORT STATE SERVICE
4000/tcp open remoteanythingNmap has confirmed that something is responding on that port.
You can then identify the service:
nmap -sV -p 4000 127.0.0.1This gives you another layer of information.
Why Port Numbers Are Not Enough
A common beginner assumption is:
22 = SSH
80 = HTTP
443 = HTTPS
5432 = PostgreSQLThese are common associations, but applications can use different ports.
For example, a development web server may run on:
3000
4000
5000
8000
8080So don't conclude what an application is doing purely from the port number.
Use service detection when you need more information:
nmap -sV -p 8080 127.0.0.1Discover Hosts on a Private Network
Nmap can also perform host discovery.
For a network you own or are authorized to administer:
nmap -sn 192.168.1.0/24The -sn option performs host discovery without the normal port scan.
Conceptually:
This can be useful for controlled environments such as:
- home networks
- development labs
- security training environments
- systems you administer
Read the Output Before Running Another Command
Consider:
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
3306/tcp filtered mysql
8080/tcp closed http-proxyDon't immediately label every open port as a vulnerability.
Instead ask:
Port 22
22/tcp open sshIs SSH expected?
Port 80
80/tcp open httpIs HTTP intentionally exposed?
Port 443
443/tcp open httpsWhat application is serving HTTPS?
Port 3306
3306/tcp filtered mysqlWhat firewall or network policy is affecting this port?
Port 8080
8080/tcp closed http-proxyWas an application supposed to be listening there?
That is the mindset you want to develop.
Save Your Results
For a repeatable check, save the output:
nmap -sV -p 22,80,443 -oN scan.txt 127.0.0.1You can also save XML:
nmap -sV -p 22,80,443 -oX scan.xml 127.0.0.1Saved results are useful when comparing:
Before deployment
↓
Deploy changes
↓
Run scan again
↓
Compare resultsAn unexpected newly exposed port can then become an investigation item.
Fast Scan vs Targeted Scan
A fast scan:
nmap -F 127.0.0.1is useful when you want a quick view of common ports.
A targeted scan:
nmap -p 22,80,443,3000,4000,5432 127.0.0.1is better when you already know the architecture.
Service detection:
nmap -sV -p 22,80,443 127.0.0.1adds information about the services behind the ports.
The best command depends on the question.
Where -O Fits
Nmap can attempt operating-system detection:
nmap -O 127.0.0.1Treat the result as an inference rather than absolute truth.
Virtualization, firewalls, unusual network configurations, and insufficient responses can affect OS detection.
For beginners, port and service detection are usually the better place to start.
Where NSE Fits
Nmap also includes the Nmap Scripting Engine.
NSE extends Nmap with scripts for different kinds of discovery, detection, and security testing.
For example:
nmap -sC TARGETHowever, don't treat NSE as something to run blindly against arbitrary systems.
Only run Nmap scripts against systems and networks where you have authorization. Some scripts can be intrusive or generate significant network activity.
A sensible learning progression is:
Basic scanning
↓
Port selection
↓
Service detection
↓
Output interpretation
↓
NSE
↓
Deeper security assessmentKaryvio Practice Lab
Build a small local application environment.
For example:
Next.js → 3000
Node.js API → 4000
PostgreSQL → 5432
Redis → 6379Then scan only those expected ports:
nmap -p 3000,4000,5432,6379 127.0.0.1Create a small inventory:
| Port | Expected Service | Observed State | Investigate? |
|---|---|---|---|
| 3000 | Next.js | Open | No |
| 4000 | Node.js API | Open | No |
| 5432 | PostgreSQL | Open | Depends on architecture |
| 6379 | Redis | Closed | If Redis is required |
Now deliberately start another local service on an unexpected port.
Scan again.
Your goal is to identify the difference between:
what your architecture says should exist
and
what the network actually exposes.
That is a real security engineering skill.
Five Commands to Remember
Basic scan:
nmap TARGETSpecific ports:
nmap -p 22,80,443 TARGETService detection:
nmap -sV TARGETHost discovery:
nmap -sn 192.168.1.0/24Save results:
nmap -sV -oN scan.txt TARGETYou don't need to memorize every Nmap option before becoming productive.
Understand these first.
Nmap Is Not a Vulnerability Verdict
An open port is an observation.
For example:
443/tcp open httpsdoes not mean:
The application is vulnerable.Likewise:
22/tcp open sshdoes not mean:
The server has been compromised.And:
3306/tcp open mysqldoes not automatically mean:
The database is insecure.Nmap gives you visibility.
The security investigation comes afterward.
The Better Security Question
Instead of asking:
"How many open ports are there?"
ask:
"Which exposed services are expected, and which ones require investigation?"
That shift changes how you use Nmap.
You begin connecting scan results with:
- application architecture
- firewall configuration
- cloud security groups
- container port mappings
- server configuration
- network segmentation
- service ownership
Final Takeaway
Nmap is easiest to learn when every command has a purpose.
Start small:
nmap 127.0.0.1Then narrow the investigation:
nmap -p 22,80,443 127.0.0.1Identify services:
nmap -sV -p 22,80,443 127.0.0.1Save the result:
nmap -sV -oN scan.txt 127.0.0.1The goal isn't to memorize hundreds of flags.
The goal is to look at a network result and know what question to ask next.
Learn the output. Understand the network. Then learn the tool.







Comments (0)
Be the first to share your thoughts.