Skip to main content

Port

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/network-port

In short

A port is a number from 0 to 65535 that identifies a specific program or service on a device, so traffic reaching an IP address gets to the right application.

What is a port in networking?

In networking, a port is a number that identifies a specific program or service running on a computer. An IP address gets data to the right machine, and the port number gets it to the right application on that machine. Port numbers range from 0 to 65535 and are used by both TCP and UDP.

When a server program starts, it listens on a port, such as a web server waiting on port 443. A client connecting to it uses a temporary port of its own, called an ephemeral port, so each connection is identified by the combination of both IP addresses and both ports. Ports 0 to 1023 are well-known ports reserved for common services, such as 22 for SSH, 53 for DNS, 80 for HTTP, and 443 for HTTPS.

Think of an IP address as the street address of an apartment building and the port as the apartment number. The mail carrier gets the letter to the building, and the apartment number decides who receives it. Developers meet ports constantly, for example when a local development server runs at localhost:3000 or when a firewall rule allows only port 443.

A network port is not the same as a physical port, such as a USB or Ethernet socket on a device; a network port is purely a number in software. The same word is also used for adapting software to run on another platform, which is unrelated. Only one program can listen on a given port and address at a time, which is why starting a second one fails with errors like EADDRINUSE (address already in use).

Key takeaways

  • A port number identifies a specific program or service on a device.
  • Port numbers range from 0 to 65535, and TCP and UDP each have their own set.
  • Well-known ports include 22 (SSH), 53 (DNS), 80 (HTTP), and 443 (HTTPS).
  • A connection is identified by source IP, source port, destination IP, and destination port.
  • Only one program can listen on the same port and address at a time.

Example

Listening on a port and connecting to itbash
# Start a simple web server listening on port 8000
python3 -m http.server 8000

# In another terminal, send a request to that port
curl http://localhost:8000/

# List programs listening on TCP ports (Linux)
ss -tlnp

Readers ask

What is the difference between an IP address and a port?

An IP address identifies a device on a network, while a port identifies a specific program or service on that device. Together, as in 192.168.1.10:443, they point to one exact destination.

What does localhost:3000 mean?

localhost refers to your own computer, and 3000 is the port where a program, often a development server, is listening. Opening that address in a browser connects to that program on your machine.

What does it mean when a port is open?

An open port has a program listening on it, and the firewall allows traffic to reach it. Closing unused ports reduces the number of ways an attacker can reach a machine.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings