Skip to content

Port Numbers#

I have a question for you: what happens if you have two TCP services running on one computer and you want to talk to one of them? How does the client/server model know what service you want to connect to? That's where port numbers come into play.

With TCP (and UDP, which we cover later), a port number is used to identify what service you want to talk to on the remote server. Let's look at an example.

When you request in your web browser, it knows you want to connect a remote system with the hostname (covered in DNS) via the protocol HTTPS (explained later.) So the remote server is using the HTTPS protocol to communicate with clients (your browser.)

Because HTTPS is a known protocol, your browser knows two things:

  1. It needs to connect using TCP;
  2. It needs to connect to port 443;

A service like HTTPS listens on a particular port - 443 - for new, inbound TCP connections. This is also called a "socket." So the webserver software creates a socket that is bound to port 443 using the TCP protocol. Once the connection is complete, the browser then uses the protocol HTTPS to "talk" to the remote system. We covered this conversation in the overview of protocols.

Your browser will also use a "socket", locally, when communicating with the web server at, but the port number will be random. Unlike the web server which needs to listen on a fixed, known port (otherwise how would you know what to connect to?) your local client can use a random port number from a large range, picked at random. The client needs this port so that the networking stack in your kernel knows where to send the replies from the remote web server.

Common Ports#

There are literally thousands of known port numbers used by a whole variety of software suites, but there are just a handful you need to be aware of. I've listed them below.

Port Software/Use
20 + 21 FTP (insecure protocol; don't use)
22 Secure SHell (SSH)
25 Simple Mail Transfer Protocol (SMTP); a.k.a the sending of email
53 Domain Name System (DNS); but it's actually used via UDP mostly
80 HyperText Transfer Protocol (HTTP); a.k.a "the web"
110 Post Office Protocol v3 (POP3); a.k.a the receiving of email
143 Internet Message Access Protocol (IMAP); the receiving of email
179 Border Gateway Protocol (BGP)
389 Lightweight Directory Access Protocol (LDAP)
443 HTTP Secure; a.k.a "the web" but encrypted/secure
587 SMTP over TLS/SSL; a.k.a the sending of email over encryption
1433/1434 Microsoft SQL Server
3306 MySQL database
3389 Windows Terminal Server (RDP)
5432 PostgreSQL database

And so, so many more. Review the complete list over at Wikipedia.

Just remember that you're not expected to remember them all. I'd argue you only really need to recognise the important ports you're going to see daily as a working system administrator in a Cloud environment:

  • HTTP on 80 and HTTPS on 443
  • SSH on 22
  • DNS on 53

And not so daily from an administrative perspective (or at all in some cases), but used heavy by everyone daily (minute by minute for some devices like mobile phones):

  • SMTP on 25 and 587
  • POP3 on 110
  • IMAP on 143

Or put another way: email.

Special Ranges#

There are some special port ranges you should be aware of, as well as some rules with regards to what ports can be used by a process.

Well known port numbers range between 0 all the way through to 1023. These are the port numbers used for the most common services we'll come to know and understand throughout this course. These port numbers include everything above under "Common Ports" until port 1433/1434, non-inclusive. These are also known as privileged ports, and root level (or Administrator on Windows) access is required to bind a process to these port numbers.

Ports 1024 to 49151 are considered "registered ports".

Ports 49151 to 65535 are called "dynamic ports".