The Short Answer
| TCP | UDP | |
|---|---|---|
| Connection | Handshake first | None |
| Lost data | Resent | Gone |
| Order | Kept | Not kept |
| Header | 20 to 60 bytes | 8 bytes |
| Flow control | Yes | No |
| Typical use | Web, SSH, mail, databases | DNS, NTP, VPNs, streaming |
How TCP Works
Before any data flows, the two sides exchange three packets: the client sends SYN, the server answers SYN-ACK, and the client confirms with ACK. From then on every byte has a sequence number. The receiver acknowledges what arrived, the sender resends what was not acknowledged in time, and the receiver puts everything back in order before the application sees it. TCP also slows down when the network is congested and when the receiver cannot keep up.
The result is a reliable stream of bytes, at the cost of one round trip before the first byte and some extra waiting when a packet is lost.
How UDP Works
UDP sends each message as a separate datagram, with source port, destination port, length, and checksum, and nothing else. There is no handshake, no acknowledgment, and no resending. If the application needs any of that, it builds it itself.
That suits short questions and answers, such as a DNS lookup that fits in one packet each way, and live data where a late packet is worse than a lost one, such as voice calls. DNS also uses TCP when an answer is too large for UDP and for zone transfers.
QUIC and HTTP/3
QUIC is a transport protocol that runs on top of UDP and adds its own connections, encryption, ordering, and retransmission. HTTP/3 runs over QUIC, so a web server that offers HTTP/3 listens on a UDP port, usually 443, in addition to TCP port 443. Browsers usually connect over TCP first and switch to HTTP/3 once the server advertises it.
Which Services Use Which
- TCP: HTTP and HTTPS, SSH, SMTP and IMAP, MySQL, PostgreSQL, Redis.
- UDP: DNS queries, NTP time sync, WireGuard and most OpenVPN setups, syslog, voice and video calls, HTTP/3.
- Both: DNS, which falls back to TCP for large answers.
The full list is in common port numbers.
On Your Server: See TCP and UDP Sockets
sudo ss -tulpn-t and -u select TCP and UDP, -l shows listening sockets, -p the process, and -n prints numbers instead of names. A shortened example:
Netid State Local Address:Port Process
udp UNCONN 127.0.0.53%lo:53 users:(("systemd-resolve",...))
tcp LISTEN 0.0.0.0:22 users:(("sshd",...))
tcp LISTEN 0.0.0.0:443 users:(("nginx",...))LISTEN: a TCP socket waiting for connections.UNCONN: a UDP socket. UDP has no connections, so this is the normal state for a UDP service.
On Ubuntu, SSH uses systemd socket activation by default, so the line for port 22 can name systemd as well as, or instead of, sshd.
To see live TCP connections, run ss -tn. States such as ESTAB and TIME-WAIT exist only for TCP. Which program owns a port is also shown by lsof.
Firewall Rules Name the Protocol
Port 443 over TCP and port 443 over UDP are two different openings. With ufw on Ubuntu and Debian:
sudo ufw allow 443/tcp
sudo ufw allow 443/udp
sudo ufw allow 51820/udpA rule without a protocol, such as sudo ufw allow 53, opens both. With firewalld on AlmaLinux and Rocky Linux:
sudo firewall-cmd --permanent --add-port=51820/udp
sudo firewall-cmd --reloadOpen only what the service uses: a VPN on UDP does not need the same TCP port.
Testing and Troubleshooting
- TCP, refused: the server answered that nothing listens on the port. See connection refused.
- TCP, timed out: usually a firewall dropped the packets without answering, or the host is down.
- UDP, no answer: a closed UDP port normally triggers an ICMP "port unreachable" reply, but a filtered port stays silent, and so does an open service that ignores an empty packet. A port check with
nc -zutherefore cannot reliably tell open from blocked. Test with the real client, or listen withnc -luon one side and send on the other, as shown in the nc command.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations