What is a port in networking?
Definition
A port is a 16-bit number identifying one endpoint of a transport connection, so a single address can carry many independent conversations at once.
Every connection you open is told apart from every other by four numbers and a protocol: your address, your port, the remote address and the remote port. Change any one of them and it is a different connection. That is how one machine can hold thousands of conversations at once, and it is also where a busy scraper behind a proxy runs out of room long before it runs out of bandwidth.
protocol source address : source port --> destination address : destination port
TCP 192.0.2.10 : 51544 --> 198.51.100.7 : 8000
(your machine) (picked by the (the proxy gateway) (the gateway's
operating system) listening port)
The three ranges
RFC 6335 divides the 16-bit space into three parts, and IANA keeps the registry of who has been assigned what.
| Range | RFC 6335 name | How it is assigned | Where you meet it |
|---|---|---|---|
| 0 to 1023 | System Ports | IANA, with stricter review | 80 and 443 for web targets; 1080 is registered for SOCKS |
| 1024 to 49151 | User Ports | IANA, on request | Most proxy gateway ports, which are vendor choices rather than registrations |
| 49152 to 65535 | Dynamic Ports | Never assigned | Set aside for local and dynamic use, which is where outbound source ports are meant to come from |
A registration is a convention, not enforcement. Any service may listen on any port it can bind, which is why a port number tells you what a service probably is and never what it certainly is.
The source port comes from a smaller pool than you think
Operating systems do not all follow the IANA dynamic range for outbound ports. Read directly on two machines:
# macOS 26.6.2
$ sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.last: 65535
# Linux 6.8.0
$ cat /proc/sys/net/ipv4/ip_local_port_range
32768 60999
That is 16,384 source ports on the Mac and 28,232 on Linux, whose default the kernel documentation also gives as 32768 and 60999. Each simultaneous connection from one source address to one destination address and port uses one of them. Closing a connection does not hand the port back at once either: the side that closes first holds it in TIME-WAIT. RFC 9293 sets that state at twice the maximum segment lifetime, which it takes as two minutes, and Linux shortens it to 60 seconds in include/net/tcp.h. With reuse of TIME-WAIT ports off for non-loopback traffic, which is the Linux default, 28,232 ports over 60 seconds works out to about 470 new connections a second to one destination before the range runs dry.
Here is the part specific to proxies. Through a proxy, every connection you open has the same destination: the gateway’s address and port. Fifty target sites do not spread the load; they all draw on one range. The failures arrive suddenly at a threshold, often as EADDRNOTAVAIL or “Cannot assign requested address” on Linux, and they look like the provider failing when the cause is on your machine. The fix is to reuse connections rather than open one per request. The Node.js proxy guide measured five requests opening five tunnels with a fresh agent each time and one tunnel with a shared agent, and the Python guide covers bounding concurrency so the ceiling is never reached.
The two ranges were read on 21 October 2026: sysctl on a Mac running macOS 26.6.2 and /proc on a Linux 6.8.0 server, one reading each. Both are defaults and can be changed by an administrator, so read your own.
Ports as a proxy control surface
Many providers put one gateway hostname in front of everything and use the port to select behaviour: the country of the exit node, whether the address rotates per request, or which sticky session you get. It needs no protocol extension and works with any client, which is its whole appeal. It is a vendor convention, not a standard, so the mapping differs between providers and can change. The same choices are often available as parameters inside the proxy username instead, a pattern shown in the rotation guide.
The destination port is separate. It travels inside your request, as the target of a CONNECT or the port in an absolute URL, and the proxy uses it unchanged for the onward connection. A proxy that rewrote it would break most protocols. Port forwarding, which publishes an internal service outward, is a different thing again, and one that is not available at all behind carrier-grade NAT without the carrier’s help.
Frequently asked questions
Why does my proxy provider give me a different port for each country?
What are ephemeral ports and why do they run out?
Does a proxy change the destination port?
Sources
- RFC 6335: IANA procedures for the port number registry, System, User and Dynamic ranges
- IANA: Service Name and Transport Protocol Port Number Registry (1080 registered as socks)
- RFC 9293: Transmission Control Protocol, connections as socket pairs and the 2MSL TIME-WAIT state
- Linux kernel documentation: ip_local_port_range default 32768 60999 and tcp_tw_reuse default 2
- Linux source, include/net/tcp.h: TCP_TIMEWAIT_LEN defined as 60 seconds