Port Forwarding is a networking technique that forwards traffic arriving at a specific port from an external network to a designated IP address and port on the internal network. The routers used at home or in the office let multiple devices use the Internet through a single public IP via NAT (Network Address Translation), and in this setup, port forwarding configuration is required to reach an internal server from the outside.
In a NAT environment, internal devices use private IPs (192.168.x.x, 10.x.x.x, etc.). Since these private IPs cannot be accessed directly from the outside, you set a rule on the router such as "when traffic arrives from outside on port 80, send it to internal 192.168.0.100:80." This is the essence of port forwarding. It is like calling a company's main number and being connected to an extension.
There are several types of port forwarding. Local Port Forwarding connects a local port to a port on a remote server through an SSH tunnel. Remote Port Forwarding connects a port on a remote server to a local service, allowing the local server to be accessed from the outside. Dynamic Port Forwarding behaves like a SOCKS proxy and tunnels all traffic.
In modern development environments, port forwarding is used in many ways. You expose a local development server externally for webhook testing or client demos (ngrok, Cloudflare Tunnel), run media servers, NAS, and game servers on a home server, and securely connect to a database behind a firewall through an SSH tunnel. In cloud environments, you can also access a Pod directly with Kubernetes' kubectl port-forward command.