Network & delivery

10 min readUpdated

What is a port? TCP and UDP ports, port ranges and a common ports list

Quick answer

A port is a 16-bit number, from 0 to 65535, in every TCP and UDP header that tells the receiving host which program a packet belongs to: the IP address finds the machine, the port finds the service. IANA divides the numbers into well-known ports (0 to 1023), registered ports (1024 to 49151) and dynamic or ephemeral ports (49152 to 65535). TCP and UDP keep separate port spaces, so TCP 53 and UDP 53 are different sockets.

01What is a port in networking?

A port is a number that identifies one endpoint of a conversation on a host. The IP header carries source and destination addresses, which get a packet to the right machine; the TCP or UDP header carries a 16-bit source port and destination port, which get it to the right program on that machine. Sixteen bits give 65,536 values, 0 to 65535.

A server program asks the operating system to bind a socket to an address and port, for example TCP 443 on every address, and then listens. A client that connects picks a temporary port of its own, so each TCP connection is identified by five values: protocol, source address, source port, destination address and destination port. That 5-tuple is why one web server on port 443 can hold thousands of connections at once: each differs in the client's address or port.

The word also names a physical socket on a switch or router. This page is about the logical port of TCP and UDP, which lives in the transport layer of the TCP/IP model.

02TCP ports vs UDP ports: are they the same?

No. TCP and UDP keep separate port spaces. TCP 53 and UDP 53 are two different sockets, and a DNS server opens both. IANA usually registers a number for the same service on both protocols, but not always: in its registry TCP 514 is the old rsh "shell" service while UDP 514 is syslog, and TCP 520 is "efs" while UDP 520 is the RIP routing protocol.

The two protocols also behave differently when nothing is listening, which is how port scanners tell open from closed:

Port stateTCP answerUDP answer
Open (a program listens)SYN-ACK: the handshake can completeWhatever the application replies, or nothing at all
Closed (nothing listens)RST: the connection is refused at onceICMP port unreachable, which RFC 1122 says a host SHOULD send
Filtered (a firewall drops it)No reply; the client times outNo reply, which looks the same as an open port that stays silent

03Well-known, registered and ephemeral port ranges

RFC 6335 (BCP 165, August 2011) divides the 65,536 numbers into three ranges, shown in the table below, and IANA keeps the registry of which service holds which number. Port 0 is reserved; a program that binds to port 0 asks the operating system for any free port.

Operating systems add rules of their own. On Linux, binding below 1024 needs root or the CAP_NET_BIND_SERVICE capability, because ip_unprivileged_port_start defaults to 1024. Client ports come from each system's own ephemeral range, which is not always the IANA one: Linux uses 32768 to 60999 by default (ip_local_port_range), while Windows has used 49152 to 65535 since Windows Vista and Server 2008, up from 1025 to 5000 before.

RangeName in RFC 6335Used for
0 to 1023System Ports, also called well-known portsLong-standing services such as 22 SSH, 25 SMTP, 53 DNS, 80 HTTP and 443 HTTPS; assigned by IANA under the strictest review
1024 to 49151User Ports, also called registered portsApplications that registered a number, such as 1433 SQL Server, 3306 MySQL, 3389 RDP and 5432 PostgreSQL
49152 to 65535Dynamic Ports, also called private or ephemeral portsNever assigned; meant for temporary client ports and private use

04How to see which ports are listening on a server

On Linux, ss -tulpn lists every listening TCP and UDP socket with the process that owns it: t for TCP, u for UDP, l for listening, p for the process and n for numbers instead of service names. Run it with sudo to see processes of other users. The output below comes from an isolated test namespace in which a small script held six sockets.

Read the local address column first. 0.0.0.0 and [::] mean every IPv4 or IPv6 address on the host, including the public one; 127.0.0.1 means loopback only. In the example, PostgreSQL on 127.0.0.1:5432 cannot be reached from outside, while 0.0.0.0:53 can unless a firewall says otherwise. UDP sockets show UNCONN because UDP has no connections. On Windows, netstat -ano lists the same with process IDs. What an outsider sees is a separate test, because a firewall can hide a listening socket.

ss output from an isolated network namespace (iproute2 6.1, Debian 12; process IDs shortened)
$ sudo ss -tulpn
Netid State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process
udp   UNCONN 0      0            0.0.0.0:53        0.0.0.0:*    users:(("python3",pid=1234,fd=7))
udp   UNCONN 0      0          127.0.0.1:323       0.0.0.0:*    users:(("python3",pid=1234,fd=8))
tcp   LISTEN 0      128          0.0.0.0:22        0.0.0.0:*    users:(("python3",pid=1234,fd=3))
tcp   LISTEN 0      128          0.0.0.0:53        0.0.0.0:*    users:(("python3",pid=1234,fd=6))
tcp   LISTEN 0      128        127.0.0.1:5432      0.0.0.0:*    users:(("python3",pid=1234,fd=4))
tcp   LISTEN 0      128             [::]:443          [::]:*    users:(("python3",pid=1234,fd=5))

# one port only, without the header line
$ sudo ss -Htlnp 'sport = :22'

# an established connection: the client side uses an ephemeral port
$ ss -tn state established
Recv-Q Send-Q Local Address:Port  Peer Address:Port Process
0      0          127.0.0.1:22       127.0.0.1:35948
0      0          127.0.0.1:35948    127.0.0.1:22

05Common ports list: what runs where, and what should face the internet

The table covers the ports that matter most on servers, with two columns most lists leave out: whether the port should ever be reachable from the whole internet, and the published bandwidth amplification factor where the service has been abused for reflection. The factor is reply bytes divided by request bytes. Figures are from CISA alert TA14-017A unless marked; RDP is from NETSCOUT (January 2021) and SLP from Bitsight (April 2023). A dash means none of those sources lists a factor, not that the port is safe.

PortTransportServiceFace the internet?Amplification
17UDPQOTD (quote of the day)Never140.3
19UDPCharGENNever358.8
20, 21TCPFTP data and controlAvoid; use SFTP instead-
22TCPSSH, see port 22Restrict to known sources, keys only-
23TCPTelnetNever (plain-text logins)-
25TCPSMTP between mail serversMail servers only-
53UDP, TCPDNS, see port 53Authoritative servers yes; resolvers only to their own users28 to 54, see DNS amplification
67, 68UDPDHCPNo, local network only-
69UDPTFTPNever60
80TCPHTTPWeb servers, ideally behind a proxy-
88TCP, UDPKerberosNo-
110TCPPOP3Prefer 995-
111TCP, UDPRPCbind (portmapper)Never7 to 28
123UDPNTPPublic time servers only; disable monlist556.9, see NTP amplification
135TCPMicrosoft RPC endpoint mapperNever-
137UDPNetBIOS name serviceNever3.8
139, 445TCPSMB file sharingNever-
143TCPIMAPPrefer 993-
161UDPSNMPNever6.3 (SNMPv2 GetBulk)
179TCPBGPConfigured peers only-
389TCP, UDPLDAP and CLDAPNever46 to 55 (LDAP), 56 to 70 (CLDAP)
427UDP, TCPSLP (service location)NeverOver 2,200 (Bitsight)
443TCP, UDPHTTPS, and HTTP/3 over QUICWeb servers, ideally behind a proxy-
465, 587TCPMail submission (TLS, STARTTLS)Mail servers only-
500, 4500UDPIPsec IKE and NAT traversalVPN gateways only-
514UDPSyslogNo-
520UDPRIP routingNever131.24 (RIPv1)
636TCPLDAPSNo-
853TCP, UDPDNS over TLS and over QUICPublic resolvers only-
993, 995TCPIMAPS, POP3SMail servers only-
1194UDPOpenVPNVPN gateways only-
1433, 1434TCP, UDPMicrosoft SQL Server and its browser serviceNever-
1900UDPSSDP (UPnP discovery)Never30.8
2049TCP, UDPNFSNever-
2375TCPDocker API without TLSNever-
3306TCPMySQL, MariaDBNever-
3389TCP, UDPRemote Desktop (RDP)Never directly; use a VPN or gateway85.9 on UDP (NETSCOUT)
3702UDPWS-DiscoveryNever10 to 500
5060UDP, TCPSIP (VoIP signalling)VoIP servers only, restricted-
5353UDPMulticast DNSNever2 to 10
5432TCPPostgreSQLNever-
5900TCPVNCNever-
6379TCPRedisNever-
8080TCPAlternative HTTP, often admin panelsAvoid-
11211TCP, UDPmemcachedNever10,000 to 51,000, see memcached amplification
27015UDPSource engine game server query (convention, not IANA)Game servers only5.5 (Steam protocol)
27017TCPMongoDB (IANA lists it for TCP)Never-

06Which ports should be open to the internet?

As few as the server's job requires, each for a reason you can name. A web server needs 80 and 443, a mail server 25 and the submission ports, an authoritative name server 53 over both UDP and TCP. Almost everything else in the table is a management, database, file-sharing or discovery protocol built for a trusted network.

  • Start from default deny and open ports one by one, as set out in firewall configuration
  • Bind internal services to 127.0.0.1 or a private address rather than 0.0.0.0, so one firewall mistake does not expose them
  • Reach management ports (22, 3389, databases) over a VPN or from a short allowlist of source addresses
  • Turn off UDP on services that do not need it; memcached has shipped with UDP disabled by default since version 1.5.6
  • Re-check with ss after installing packages, because some services start listening as soon as they are installed
  • Behind a reverse proxy, let the origin accept 80 and 443 from the proxy only; see how to hide your origin IP

07Why open UDP ports are abused for amplification

A UDP service answers whoever a packet claims to come from, and UDP source addresses can be forged. An attacker sends a small request carrying the victim's address, and the server sends its larger reply to the victim. At memcached's upper figure of about 51,000, one megabit per second of forged requests could in principle summon around 51 gigabits per second of replies, given enough exposed servers.

That is why the table says never for so many UDP services: an exposed amplifier harms someone else first, and your own uplink second, since you pay to send the replies. The mechanics and the wider family are in amplification attacks explained. TCP ports are abused differently, mostly by exhausting connection state, as in a SYN flood.

08What a reverse proxy or firewall changes about open ports

A reverse proxy or CDN carries only the protocols it speaks, normally HTTP and HTTPS. It shields those ports at the origin and absorbs floods aimed at the website, but it does nothing for SSH, mail, game or database ports on the same server, and nothing if attackers know the server's address and target another port directly.

A host firewall decides which ports answer, but it runs on the machine it protects: a flood that fills the uplink arrives before any rule is evaluated. Volumetric protection for non-HTTP ports needs filtering upstream of the link, which is network-level protection rather than a web proxy; Layer 3/4 vs Layer 7 sets out the difference.

What listens on the portDoes a web reverse proxy help?What protects it
Websites and APIs on 80 and 443Yes: the proxy terminates and filters the trafficA proxy or WAF, and an origin that only accepts the proxy
Management on 22 or 3389NoAllowlist or VPN, key-only login, rate limits
Databases and caches (3306, 5432, 6379, 11211)NoNever public: bind locally and firewall
Game and voice servers on UDPNoUpstream network filtering that understands the protocol
Authoritative DNS on 53NoAnycast DNS capacity and query filtering

Questions

Frequently asked questions

Each transport protocol has 65,536 port numbers, 0 to 65535, because the port fields in the TCP and UDP headers are 16 bits wide. TCP and UDP count separately, so a host has 65,536 TCP ports and 65,536 UDP ports. Port 0 is reserved and not used for real traffic; a program that binds to port 0 asks the operating system to pick a free port.

Well-known ports, which RFC 6335 calls System Ports, are numbers 0 to 1023. IANA assigns them to long-established services under its strictest review: 22 for SSH, 25 for SMTP, 53 for DNS, 80 for HTTP and 443 for HTTPS, among others. On Unix-like systems only privileged processes can bind to them by default. Registered ports run from 1024 to 49151.

An open port is only as risky as the program behind it. Port 443 on a patched web server is expected; a database on 3306 or memcached on UDP 11211 open to the whole internet is a serious problem. Every listening service is attack surface that has to be patched, authenticated and rate-limited, so the safe default is to expose only the ports the server's job needs.

The IP address identifies a host and travels in the IP header; the port identifies a program on that host and travels in the TCP or UDP header. A complete endpoint needs both, written as address and port, for example 203.0.113.10:443. One address can offer many services on different ports, and the same port number can be used on any number of addresses.

An ephemeral port is the temporary source port a client's operating system picks for an outgoing connection and releases when the connection closes. RFC 6335 sets aside 49152 to 65535 for this, which Windows uses, while Linux defaults to 32768 to 60999. When you open a website, your browser's connection runs from an ephemeral port on your machine to port 443 on the server.

Sources

Sources and verification

ss output produced with iproute2 6.1.0 in an isolated network namespace; Linux defaults read from /proc/sys/net/ipv4 on Debian 12; port assignments checked against the IANA service name and port number registry (CSV download); October 2026.

  1. 01RFC 6335: IANA Procedures for the Management of the Service Name and Transport Protocol Port Number Registry · IETF
  2. 02Service Name and Transport Protocol Port Number Registry · IANA
  3. 03RFC 1122: Requirements for Internet Hosts (UDP port unreachable, section 4.1.3.1) · IETF
  4. 04IP sysctl: ip_local_port_range and ip_unprivileged_port_start · kernel.org
  5. 05The default dynamic port range for TCP/IP has changed in Windows Vista and Windows Server 2008 · Microsoft Learn
  6. 06Alert TA14-017A: UDP-Based Amplification Attacks · CISA
  7. 07Microsoft RDP Reflection/Amplification DDoS Attack Mitigation Recommendations · NETSCOUT ASERT
  8. 08New high-severity vulnerability (CVE-2023-29552) discovered in the Service Location Protocol · Bitsight
  9. 09Memcached 1.5.6 release notes (UDP disabled by default) · memcached (GitHub)

Last updated