C.W.K.
Stream
Lesson 03 of 12 · published

Ports

~15 min · ports, tcp, udp, well-known

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

The apartment number on every IP

If an IP address is the building's street address, a port is the apartment number. Ports let one machine run many network services on the same IP simultaneously — web server on 80, SSH on 22, Postgres on 5432, your dev server on 5173. When you connect to 192.168.1.100:22, you're reaching apartment 22 in that building.

Ports are 16-bit unsigned integers (0 – 65,535) and split into three official ranges:

RangeNameWhat it means
0 – 1023Well-known / systemReserved for common services. Binding requires root/admin.
1024 – 49151RegisteredAssigned by IANA for specific apps.
49152 – 65535EphemeralAuto-allocated to client connections.

The ports you'll touch every day

PortServiceNotes
22SSHEncrypted remote shell — every lesson after Track 2
53DNSUDP (mostly), name resolution
80HTTPPlaintext web — increasingly rare on the public internet
443HTTPSTLS-encrypted web — the default everywhere now
3000Dev serverCommon for Node/React
5173ViteVite dev server default
5432PostgreSQLDatabase
8000Dev serverFastAPI / Django default
8080Alt HTTPCommon alternative for proxies

Ephemeral ports, briefly

When your browser opens a connection to example.com:443, the server side is :443 but the browser side is some random port like :52847. That's an ephemeral port — your OS picks a free one in the 49152–65535 range, uses it for the lifetime of the connection, then releases it.

Code

Inspect ports on your machine·bash
# macOS: what's running on port 8000?
lsof -i :8000

# All listening sockets with PIDs
lsof -i -P -n | grep LISTEN

# Linux equivalent
ss -tulnp

# Kill the process holding port 8000 (find PID, then nuke it)
lsof -ti :8000 | xargs kill -9

External links

Exercise

Start a quick Python server on port 8888: python3 -m http.server 8888. In another terminal, run lsof -i :8888 and identify the PID. Then run lsof -ti :8888 | xargs kill -9 to terminate it the same way you would if you forgot what was running on a port. Verify with lsof -i :8888 (should be empty).

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.