Networking

Ports & Protocols Explained: TCP, UDP and the Numbers Behind Every Connection

How a port number directs traffic to the right program, the difference between TCP and UDP, the well-known ports you should recognise, and how ports relate to firewalls and security.

An IP address gets data to the right machine — but a single server runs many services at once: a website, email, maybe a database and a game server. Something has to direct each arriving packet to the right program. That something is the port number, and together with the protocol (TCP or UDP) it is what a network connection is actually built from.

You can test whether a given port is reachable on a host with the Port Check tool.

What a port is

A port is a number from 0 to 65535 that labels a specific service on a device. If the IP address is the street address of a building, the port is the apartment number inside it. A complete connection is identified by four things — source IP, source port, destination IP, destination port — which is how one server can hold thousands of simultaneous conversations without mixing them up.

Ports fall into three ranges:

RangeNameUse
0 – 1023Well-knownStandard services (web, email, SSH)
1024 – 49151RegisteredSpecific applications and vendors
49152 – 65535Dynamic / ephemeralTemporary client-side ports for outgoing connections

TCP vs. UDP: two ways to send

Before the port does its job, the data rides on one of two transport protocols, and the choice is a trade-off between reliability and speed.

  • TCP (Transmission Control Protocol)reliable and ordered. It performs a handshake to open a connection, numbers every packet, confirms what arrived, and resends anything lost. Slightly slower, but nothing goes missing or out of order. Used for web pages, email, file transfer — anything where every byte must arrive.
  • UDP (User Datagram Protocol)fast and connectionless. It just fires packets off with no handshake, no acknowledgements, no resending. If one is lost, it is gone. That sounds worse, but for live video, voice calls, online games and DNS, a dropped packet is better than a delayed one — you want the latest data, not a perfect replay of old data.
💡The intuition: TCP is a phone call — connection established, every word confirmed. UDP is shouting across a room — fast, no guarantee every word lands, but fine when speed beats perfection.

Well-known ports worth recognising

PortServiceProtocol
20 / 21FTP (file transfer)TCP
22SSH (secure remote shell)TCP
25SMTP (sending email)TCP
53DNS (name resolution)UDP/TCP
80HTTP (web)TCP
443HTTPS (secure web)TCP
3306MySQL databaseTCP

This is why a web address rarely shows a port: the browser assumes 443 for https:// and 80 for http://. You only specify a port (e.g. :8080) when a service listens somewhere non-standard. Note that DNS uses port 53 — mostly over UDP for speed, falling back to TCP for large answers.

Ports, firewalls and security

Every open port is a door a program is listening behind — and a potential way in for an attacker. A firewall controls which ports are reachable, and the security principle is simple: open only the ports for services you actually offer, and close everything else. A web server might expose only 443; a database should usually not be reachable from the public internet at all.

Scanning a host for open ports is how administrators audit their own exposure — and, on the other side, how attackers find targets. Checking whether a specific port is open on a host you control, with the Port Check tool, tells you whether a service is reachable or whether a firewall is (correctly) blocking it.

⚠️Only scan or probe hosts you own or have permission to test. Port-scanning systems you do not control can be against terms of service or the law.

In practice

Put together: a connection is a source and destination IP plus a source and destination port, carried over TCP or UDP. The IP finds the machine, the port finds the program, and the protocol decides whether delivery is guaranteed or just fast. That four-part address is the foundation of every click, call and stream. See how it joins the rest of networking in IP Addressing Explained.

Frequently asked questions

What is a network port?

A port is a number from 0 to 65535 that identifies a specific program or service on a device. The IP address gets data to the right machine; the port gets it to the right application on that machine — like an apartment number after the street address.

What is the difference between TCP and UDP?

TCP is reliable and ordered: it sets up a connection, confirms delivery, and resends lost data — used for web pages, email and file transfer. UDP is fast and connectionless: it fires packets without guarantees — used for live video, voice, gaming and DNS, where speed matters more than perfect delivery.

What port does HTTPS use?

HTTPS (secure web traffic) uses TCP port 443. Plain HTTP uses port 80. Browsers default to these, which is why you rarely type a port in a web address.

Why are some ports blocked?

Firewalls block ports to reduce attack surface — every open port is a potential way in. Only the ports for services a machine actually offers should be open; closing the rest is a basic security measure.

Was this article helpful?