TCP/UDP network ports

TCP and UDP network ports

A network port is a number from 0 to 65535 that the operating system uses to deliver incoming data to the right service or application. The IP address identifies the device, while the port identifies the recipient within it. TCP delivers an ordered data stream with acknowledgments and retransmission of lost data; UDP sends individual messages without these mechanisms. For a server, both the port number and the protocol matter: opening 443/TCP and 443/UDP are two separate actions.

What is a network port?

A port is a logical address for a service, rather than a separate server component. This article covers logical ports, rather than physical RJ-45 or SFP connectors.

An apartment building makes a useful analogy. The IP address helps you find the building, and the port number identifies the apartment. A web server may accept requests on port 443, SSH on 22, and a MySQL database on 3306. There is one device, but different recipients.

To accept requests, an application binds to a local address and port. A TCP server is said to “listen on a port”: it waits for incoming connections. A UDP service receives datagrams on its bound port, although it does not establish connections in the TCP sense.

IP addresses, ports and sockets

The notation 192.0.2.10:443 combines an IP address and a port number. It identifies a communication endpoint; in TCP terminology, the combination of an address and a port is called a socket. In programming, a socket also refers to the object an application uses to work with the network.

A connection has two sides. Suppose a browser accesses a website:

  • the server accepts TCP connections on 192.0.2.10:443;
  • the user’s computer is assigned the local endpoint 198.51.100.20:53124;
  • the server’s responses return to the user’s address and port 53124.

The number 53124 is an example: the operating system usually assigns the source port. A client does not need to run a local service on 443 to browse an HTTPS website.

A TCP connection is identified by a pair of endpoints: the address and port on each side. One server port can serve many clients because their addresses or source ports differ.

A port number does not permanently bind an application to it: a web server can be moved from 443 to 8443. However, the client must know both the destination address and the application protocol.

How many ports are there, and what are their ranges?

A port number uses 16 bits. This gives 65,536 values for TCP and the same number for UDP, from 0 to 65535 inclusive. Port 0 is reserved and should not be treated as an ordinary service port.

The IANA registry defines three ranges under the rules in RFC 6335:

  • 0–1023: system ports. This range contains many well-known services, including SSH, DNS, HTTP and HTTPS.
  • 1024–49151: user ports, often called registered ports. Numbers in this range are registered for applications; for example, 3306 is associated with MySQL. However, not every number in the range is registered.
  • 49152–65535: dynamic and private ports. IANA does not assign them to specific services. They are suitable, among other uses, for temporary client endpoints.

The ephemeral port range depends on the operating system and its settings. A high port number can still be used for a server service.

Registration does not establish that traffic is safe. Seeing port 443 in a log does not prove that it carries an ordinary website or that the connection is trustworthy.

What are TCP and UDP?

TCP and UDP are transport protocols. In the OSI model, they belong to Layer 4, the transport layer; in the TCP/IP stack, they operate at the transport layer above IP. Their role is to support communication between applications on different devices.

IP handles packet delivery between network hosts. TCP or UDP adds the source and destination ports, but their approaches then diverge. Layer 2 and Layer 3 devices handle different tasks: forwarding within a network and routing between networks. Servermall’s article on Layer 1, 2 and 3 switches explains this in more detail.

How TCP works: connections and acknowledgments

TCP connections and data transmission

TCP stands for Transmission Control Protocol. As long as the connection remains operational, it delivers a stream of bytes to the application in their original order.

A normal connection is established in three steps:

  1. SYN. The client requests a connection and sends its initial sequence number.
  2. SYN-ACK. The server acknowledges the request and sends its own initial sequence number.
  3. ACK. The client acknowledges the server’s response. The two sides can then exchange data over the established connection.

This procedure is called the three-way handshake. The mechanism is described in RFC 9293, the TCP specification, which replaced RFC 793.

During transmission, TCP tracks byte sequence numbers in segments, receives acknowledgments and retransmits lost data. Flow control prevents the sender from overwhelming the receiver, while congestion control helps adapt transmission to network conditions.

These mechanisms take time: a connection must be established, and a lost segment requires waiting for the missing data to be recovered. Later bytes in the same stream cannot be delivered to the application before the missing bytes. This is called head-of-line blocking.

“Guaranteed delivery” does not mean that TCP can overcome a disconnected cable or a server that remains unavailable indefinitely. A connection can fail. A TCP acknowledgment does not mean that the application has processed a request or saved a file: the application must provide its own response.


Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data

How UDP works

UDP stands for User Datagram Protocol. A datagram is an individual message: an application sends it to a specified address and port without a preliminary UDP handshake.

RFC 768, the UDP specification, defines a short header with four fields: source port, destination port, length and checksum. It is 8 bytes long. A TCP header occupies 20–60 bytes, excluding the IP header.

UDP itself does not:

  • acknowledge receipt of messages;
  • retransmit lost datagrams;
  • restore their original order;
  • remove duplicates or provide congestion control.

Applications must therefore account for message loss and reordering. If acknowledgments or retransmissions are required, they are implemented above UDP. The checksum helps detect data corruption, but does not replace delivery tracking.

During a conversation, it can be better to skip a fragment that arrives too late. When transferring a document, losing part of the file is unacceptable. The transport choice depends on these requirements.

How TCP differs from UDP

TCP handles recovery of an ordered stream. UDP provides individual messages with fewer built-in mechanisms. UDP has lower header overhead and no connection establishment of its own, but this does not increase the link’s bandwidth.

Criterion TCP UDP
Connection Established before normal data exchange No connection establishment in the protocol itself
Delivery Acknowledgments and loss detection; if communication cannot continue, the connection fails No built-in delivery acknowledgment
Ordering Delivers an ordered byte stream to the application Does not restore datagram order
Retransmission Provided at the TCP layer Provided by the application or a protocol above UDP if needed
Header 20–60 bytes 8 bytes
Latency Connection setup and waiting for missing data take time UDP itself has neither mechanism; the outcome depends on the application and network
Examples SSH, HTTP/1.1, HTTP/2, SMTP Conventional DNS queries, many voice and gaming streams, transport for QUIC

The statement “UDP is always faster than TCP” is misleading. An application using UDP may still establish a secure session, acknowledge messages and retransmit lost data. Poorly designed transmission can also cause congestion and increase loss.

Some firewalls and public networks filter UDP more strictly. This is another consideration when choosing a transport.

TCP or UDP: what do SSH, DNS and VPNs use?

TCP and UDP in network services

  • SSH uses TCP. Commands and responses must arrive without gaps and in the correct order. SFTP runs over SSH and usually uses the same TCP port, 22.
  • Conventional DNS uses both UDP and TCP. Small queries and responses are more often sent over UDP. TCP is needed, for example, when retrying a query after a truncated response and for full zone transfers. TCP support for DNS is specified in RFC 7766.
  • OpenVPN supports both transports. The OpenVPN documentation recommends UDP when the network allows it. Carrying TCP inside a TCP tunnel creates two layers of retransmission and congestion control, which can impair performance when packets are lost. TCP remains an option for networks where UDP is unavailable.
  • Internet telephony and games often use UDP for real-time data. Authentication, session management and content downloads may still use TCP. Describing an entire service as exclusively a “UDP application” is not always accurate.

Why modern HTTPS also runs over UDP

HTTP/1.1 and HTTP/2 use TCP. HTTP/3 runs over QUIC on top of UDP, as specified in RFC 9114.

There is no contradiction here: UDP provides the foundation, while QUIC adds a secure connection, acknowledgments, loss recovery and congestion control. Reliability comes from the protocol above UDP, rather than from UDP itself.

QUIC divides communication into independent streams: a loss in one stream does not have to block delivery in the others. Missing data still has to be recovered within the affected stream.

For HTTPS with HTTP/3, both 443/TCP and 443/UDP are usually allowed. If UDP is blocked, a client may fall back to HTTP over TCP. A working website therefore does not prove that HTTP/3 is available.

Common ports

The table below lists common default assignments. Check the actual port in the configuration: a familiar number may be used by a different application.

Port Service Transport and purpose
20, 21 FTP TCP: 21 for the control connection; 20 as the server’s data source port in classic active mode
22 SSH, SFTP TCP: remote administration and file transfer over SSH
25 SMTP TCP: primarily email transfer between mail servers
53 DNS UDP and TCP: DNS queries, responses and service operations
80 HTTP TCP: plain HTTP, often redirecting to HTTPS
110, 143 POP3, IMAP TCP: email access; encryption depends on the mode and settings
443 HTTPS TCP for HTTP/1.1 and HTTP/2; UDP for HTTP/3 over QUIC
3306 MySQL TCP: client connections to a database
3389 RDP TCP and UDP: remote desktop; UDP use depends on the mode and connection conditions
8080 Alternative HTTP TCP: applications, proxy servers and test web services

What is port 443 used for?

443 is the standard HTTPS port. Browsers use it for https:// addresses unless a port number is explicitly specified. The transport depends on the HTTP version.

Encryption is provided by TLS as used by the relevant protocol, rather than by the number 443. Moving an unencrypted service to this port does not make it secure. Conversely, HTTPS can run on another port when the server and client are configured correctly.


How does port 8080 differ from port 80?

80 is the standard port for http:// addresses. 8080 is often used as an alternative: for example, when the main web server already occupies 80 and another application needs to accept requests separately.

The address http://192.0.2.10:8080 explicitly specifies the port. If you remove it, the browser will connect to 80, where a different website may be running or nothing may be listening.

An application on 8080 can remain inside the network, with external requests received over HTTPS on 443 and forwarded to it. There is then no need to expose the internal port.

Ports 21 and 22: FTP and SFTP

Server and network infrastructure

Server and network infrastructure.

Source: Pexels

Port 21/TCP is used for the FTP control connection. Data uses a separate connection: in active mode, the server traditionally sends it from port 20; in passive mode, the client connects to an agreed server port. Allowing only port 21 is therefore sometimes insufficient.

22/TCP usually accepts SSH connections. It also carries SFTP, a file transfer protocol implemented as an SSH subsystem. This is not “FTP on another port”: the communication mechanisms and security differ.

Plain FTP does not encrypt passwords or files. Use SFTP or FTP over TLS, known as FTPS, for protection.

What are ports 25 and 53 used for?

25/TCP is used to exchange email between servers. User applications often submit email through 587 or 465. Port 25 alone is not enough for an entire email service.

53 is the standard port for conventional DNS. A name server must be reachable over the transports required for its role. If only 53/UDP is allowed, some small queries will work, while operations requiring TCP may fail. The result is a frustrating situation: “DNS seems to work”, but some requests do not get through.

Open ports: how to check them and close unnecessary access

“An open port” can mean two different things: an application is accepting requests on the server itself, or it is actually reachable from the required network. These conditions are related, but they are not equivalent.

For example, a service may listen on 443 while a firewall drops the packets. Alternatively, an allow rule may be configured while the application is stopped, leaving nothing to receive the traffic.

Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data

Open, closed and filtered ports

A network check usually distinguishes the following states:

  • Open: a service accepts TCP connections or UDP datagrams, and the check has received a response confirming this.
  • Closed: the device is reachable, but no service is accepting traffic at the selected endpoint. TCP usually returns a connection reset; UDP may trigger an ICMP port-unreachable response.
  • Filtered: filtering prevents the check from reliably determining whether the port is open. Packets may be silently dropped, or a rejection message may be returned.

Silence alone does not prove that a firewall is responsible: packet loss, an unreachable host or an application that does not respond to an unfamiliar request are also possible. This is especially noticeable with UDP. A scanner may therefore report open|filtered, meaning open or filtered, without being able to distinguish between them.

The result also depends on where the check is run. A port may be reachable from a management network but inaccessible from the internet. For an administrative interface, this is normal and often desirable.

53/TCP and 53/UDP are separate receiving endpoints. Both transports can use the same number at the same time. Restarting the server will not fix a mismatch where “TCP was opened, but the application uses UDP”: the protocol must match in the service configuration and the network rules.

How to view ports in Linux

Use ss to view local sockets:

sudo ss -lntup

The command shows listening TCP and bound UDP sockets, numeric addresses and ports, and their associated processes. Administrator privileges are required to view process details for other users. Older systems may use netstat, but ss is generally more convenient for current troubleshooting.

For TCP, expect the LISTEN state. UDP often shows UNCONN: the absence of a TCP-style connection is normal and does not mean the service is disabled.

Check the local address as well as the port number:

  • 127.0.0.1:8080: accepts traffic only through the local IPv4 loopback interface;
  • 0.0.0.0:8080: bound to all local IPv4 addresses;
  • [::]:8080: bound to the IPv6 unspecified address; whether it also accepts IPv4 depends on socket and system settings.

Binding to all addresses does not bypass network filtering. For a container or virtual machine, also consider its surrounding network and port publishing configuration.

How to check a port in Windows

Checking network ports in Windows

The following command shows local connections and listening endpoints:

netstat -ano

The -a option includes listening ports, -n keeps addresses and ports numeric, and -o adds the process identifier, or PID. Use it to find the application in Task Manager. A TCP port waiting for connections has the LISTENING state; UDP is displayed without this state.

To test access to a specific TCP port from another computer, use PowerShell:

Test-NetConnection -ComputerName 192.0.2.10 -Port 443

Replace the example address with your server’s address. The TcpTestSucceeded field indicates whether a TCP connection was established. This command does not test UDP, the HTTPS certificate or the website itself: a successful connection only establishes that the TCP endpoint is reachable.

How to check external access with Nmap

To check selected TCP ports from a separate machine, use:

nmap -sT -Pn -p 22,80,443,8080 192.0.2.10

The -sT option tests TCP connections, -Pn skips initial host discovery, and -p specifies the ports. Enter your server’s address; test systems owned by others only with the owner’s permission.

Running this from a computer on the same local network will not show how the server appears from the internet. To check published access, use a machine outside the network being tested. UDP requires the separate -sU mode; the TCP command above provides no information about it.

The service name displayed by a scanner may come from a port-number reference database. It does not prove that the corresponding application is actually running on that port.

Use tcpdump and Wireshark to inspect the packets themselves. They help show whether a request leaves, whether a response arrives, and where communication stops.

How to close unnecessary access

The method depends on whether the application is needed at all. Stop unused services and disable their automatic startup. Bind services needed only by the server itself to a local address. For internal applications, restrict access to the required networks or addresses.

A firewall block restricts requests but does not stop the application. Conversely, stopping a service does not remove an old allow rule. After making changes, repeat the check from the side of the network whose access rules were changed.

Before restricting a remote management port, make sure another working access method is available. Otherwise, you may lock yourself out and have to continue through the server’s management console.


Ports and server security

A port number is not a vulnerability in itself. Risk comes from the exposed service, its settings, software flaws and overly broad access rights. The administrator’s task is therefore to make only the required applications available, and only to the users who need them.

A public website usually needs external access to its web service. Avoid unnecessarily exposing databases, control panels and remote desktops to the internet. A safer approach is to access RDP and database service ports through a VPN with user authentication and role-based restrictions.

Firewalls and access restrictions

A firewall is needed both on the server itself and at the network boundary. Rules determine who can connect, where they can connect, and which protocol they can use. Security tools can also analyze applications and events; Servermall offers network security solutions.

Scanning and password guessing are common threats to TCP services. Updates, keys or multifactor authentication where supported, and restrictions on connection sources and login attempts help reduce the risk. Moving SSH from 22 to a high port reduces some automated noise, but does not replace these measures.

UDP has another characteristic risk: open services that return large responses can participate in reflected DDoS attacks. An attacker spoofs the victim’s address, and the server sends responses to the victim. If a response is substantially larger than the request, amplification occurs. Recursive DNS, for example, should therefore be restricted to trusted clients, with request and response rates controlled.

NAT and port forwarding

NAT and port forwarding

NAT translates network addresses and, in the common setup where devices share a public IPv4 address, port numbers as well. For inbound access, configure port forwarding on the router or network gateway: for example, forward requests to external port 443/TCP to 192.168.1.10:443 inside the network. Port forwarding neither starts nor protects the service; filtering rules must be enforced separately. If the ISP also uses NAT, a rule on your own device may be insufficient. These tasks are explained in more detail in “What is a router?”.

Do not treat the absence of port forwarding as universal protection: a server may be reachable through another route, such as a public IPv6 address. Check IPv6 firewall rules separately, even if the familiar IPv4 setup uses NAT.

Frequently asked questions

TCP or UDP: which should you choose for your service?

TCP is suitable for an ordered stream without gaps. UDP is suitable for individual messages when the application handles loss, reordering and congestion. With an existing application, use the transport supported by its developer.

Can one application listen on several ports?

Yes. For example, a web server accepts HTTP on 80 and HTTPS on 443. An application can create several sockets for different addresses, ports and protocols. The reverse is also possible: one port can serve several websites through a shared web server that distinguishes requests by the website’s name.

Can a web server run on a port other than 80?

Yes, for example on 8080. Specify the port explicitly in the address, or use a proxy server on the standard port. Application settings and network rules must match. Changing the number does not enable encryption.

Why might a port already be in use?

Another process is usually already bound to the same address, port and protocol. Find it with ss or netstat, and decide which service should accept requests. TCP and UDP using the same number does not itself cause a conflict.


Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data
Comments
(0)
No comments
Write the comment
I agree to process my personal data

Next news

Be the first to know about new posts and earn 50  €