In networking, a port is a number that tells a computer which program should receive a piece of incoming traffic. If an IP address is the street address of a building, the port is the apartment number: it gets the delivery to the right door inside.
How port numbers route traffic
Ports belong to the TCP and UDP protocols and range from 0 to 65535. A server program "listens" on a port, and a client connecting to that address and port is handed to it. Your own device also picks a temporary port for its side of each connection, which is how one laptop can have dozens of browser tabs talking to the same site without mixing up the replies.
Ports 0 to 1023 are the well-known range, assigned by IANA to standard services. A few you will meet:
- 80: HTTP, unencrypted web traffic.
- 443: HTTPS, encrypted web traffic.
- 22: SSH, remote server login.
- 25, 587 and 465: sending email (SMTP).
- 53: DNS lookups.
Why you rarely type a port
Browsers assume 443 for https:// and 80 for http://, so https://example.com really means https://example.com:443. You only see port numbers when something runs on a non-standard one, such as a development server at localhost:3000 or a router admin page on 8080.
Example: setting up email in an app
A shop owner connects their website's contact form to their email provider. The settings ask for an SMTP host and port. Choosing 587 with STARTTLS or 465 with SSL works; choosing 25 often fails, because many cloud hosts and home internet providers block outgoing traffic on port 25 to limit spam. A wrong port here is one of the most common reasons form emails never arrive.
Ports and security
Every open port is a program that strangers can try to talk to. A firewall controls which ports accept connections from outside. A public web server usually needs only 80 and 443 open to the world, with SSH limited to trusted addresses.
Mistakes involving ports
- Exposing a database port to the internet. Database ports such as 3306 for MySQL or 5432 for PostgreSQL should not be reachable from everywhere.
- Two programs on one port. Only one can listen; the second fails to start with an "address in use" error.
- Forgetting the firewall after changing ports. The service runs, but nobody can reach it.
- Confusing a port with a physical socket. Network ports are numbers in software, not the USB or Ethernet holes on a device.
Related terms
- IP address: the machine a port number belongs to.
- Firewall: decides which ports are reachable.
- Localhost: where development ports are most visible.
- Web server: the program listening on 80 and 443.