What Is Port Scanning? How It Works and How to Defend Against It

Port scanning shows up constantly in security news -- here is what the technique actually does, step by step.

What port scanning actually is

Port scanning is the technique of systematically attempting connections to many ports on a target IP address to determine, for each one, whether it is open, closed, or blocked by a firewall.

The three possible results

Each scanned port comes back as one of three states: open (a service responds), closed (the connection is actively refused), or filtered (there is no response at all, making it unclear whether a firewall is silently blocking it).

The most common technique: a TCP SYN scan

Rather than completing a full three-way TCP handshake, a SYN scan sends only the initial SYN packet and reads the response type to infer the port's state. It leaves a lighter connection trail and can check many ports quickly, which is why it is the most widely used scanning method.

Why attackers use it

An attacker scans a target to map out which services are running before attempting anything else, looking specifically for outdated software versions or administrative ports that were left open by mistake as potential entry points.

Why administrators use the same technique

Server operators and security teams run the same kind of scan against their own infrastructure to catch ports that were accidentally left open -- a practice usually called a vulnerability assessment or penetration test.

The basics of defending against it

Turning off services and ports you are not actually using, blocking unnecessary inbound connections at the firewall, and exposing only what genuinely needs to be reachable from the outside are the fundamental defenses against port scanning.

A scan alone is not an attack

Scanning a port only reveals whether it is open -- it does not, by itself, break into anything or cause damage. The real risk comes afterward, if the scan uncovers a genuinely vulnerable service that then becomes the next target.

Scanning networks you do not own or manage can be illegal

This guide is general technical information, not legal advice -- scanning laws vary by jurisdiction, and running scans against systems or networks you do not own or have explicit permission to test can violate acceptable-use policies or the law in many places. Only scan infrastructure you control or are authorized to assess.

Frequently Asked Questions

Is it immediately dangerous if my computer gets port-scanned?

The scan itself is just information gathering and does not cause harm on its own. It only becomes a real concern if the scan reveals a genuinely vulnerable service or a port that was left open unnecessarily, since that can invite a follow-up attack.

Are home routers actually targeted by port scans?

Yes -- any device reachable at a public IP address on the internet can be scanned, and home connections are no exception. It is worth periodically checking for port-forwarding rules or UPnP-opened ports you no longer actually need.