Skip to content
IT glossary
BackendUpdated December 3, 2026

Port

Порт

A network port is a number that helps the operating system deliver incoming data to the right application or connection. An IP address tells traffic where to go; a port helps identify who should receive it there.

Why ports exist

A single machine can run a website, a database, and an SSH service on the same IP address. Ports let those services receive traffic separately. For example, PostgreSQL normally accepts TCP connections on port 5432, while SSH defaults to TCP port 22. These are conventions, not restrictions: a service can use another port as long as its clients know where to connect.

What happens when a client connects

TCP and UDP headers carry both a source port and a destination port. Each is a 16-bit field, so the values range from 0 to 65535. Port 0 is reserved; when a program asks the OS to bind a socket to port 0, it is typically asking the OS to pick an available port instead.

A TCP server binds a socket to a local address and port, then listens for connections. When a client connects, its operating system usually assigns a temporary source port. The server keeps its listening socket and gets a separate socket for each accepted connection. Within TCP, a connection is identified by four values: the source IP address, source port, destination IP address, and destination port. That's why two clients can connect to the same server port without their data getting mixed up.

UDP also uses ports, but it sends datagrams without first establishing a connection. TCP and UDP have separate port spaces, so a service listening on 8080/TCP doesn't automatically receive packets addressed to 8080/UDP.

Example: two ports, one web request

Suppose a browser opens https://example.com. The URL omits the port, so the browser uses the HTTPS default, 443. On the server, Nginx accepts the request on that port and forwards it over a separate connection to an application at 127.0.0.1:8080. The browser only talks to the public endpoint; it doesn't need to know the application's port. Because the application is bound to the loopback address, other machines can't connect to it directly.

Common mistakes and interview questions

Why can I reach a service locally but not from another machine? Start with the bind address. 127.0.0.1 is local only, while 0.0.0.0 tells a service to listen on all local IPv4 addresses. Even then, a firewall or missing port mapping can prevent remote access. Listening and being reachable are different things.

Can two servers use the same port? The port number alone isn't enough to answer. They can use the same number with different transport protocols or bind to different specific local IP addresses. Two independent listeners trying to bind to the same address, port, and protocol normally conflict unless socket sharing is explicitly configured.

Does port 443 mean traffic is encrypted? No. The number is a default for HTTPS; TLS provides the encryption. A service can run HTTPS on a different port or serve unencrypted traffic on 443.