Skip to main content

What is a port?

A port is a logical number at the transport layer (L4) used to identify a specific application or process on a device.

Simply put: a port is needed to determine which exact application on the computer the data is intended for.


Why a port is needed

The IP address answers the question:

which computer to send the data to

The port answers the question:

which program on that computer to pass the data to

Without ports:

  • data would reach the device
  • but the system would not know which application to hand it to

How a port is used in practice

Data transmission always uses two ports:

  • source port - which application the data was sent from
  • destination port - which application it is intended for

Example:

  • browser → port 443 (HTTPS)
  • mail client → port 25 (SMTP)

Port range

A port is a number from 0 to 65535.

Main ranges:

1. Well-known ports (0-1023)

  • standard services
  • usually require administrator privileges

Examples:

  • 80 - HTTP
  • 443 - HTTPS
  • 22 - SSH
  • 25 - SMTP

2. Registered ports (1024-49151)

  • applications and services
  • often used by servers and programs

3. Dynamic / Ephemeral ports (49152-65535)

  • temporary ports
  • usually used by clients
  • assigned automatically by the OS

Ports and protocols

Important for the interview. Ports exist only together with a protocol:

  • TCP port 80 ≠ UDP port 80
  • TCP and UDP have separate port spaces

What is important to remember

  • a port is not a physical connector

  • a port is a logical concept

  • a port belongs to the transport layer

  • the combination:

    IP + port + protocol

uniquely identifies a connection

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.