How do you port-forward to a pod with kubectl?

Kubernetes (kubectl) · Manage Resources · updated 2026-08-23

kubectl port-forward [pod] 8080:80 — Port forward

kubectl port-forward [pod] 8080:80 maps local port 8080 to port 80 inside the pod, so http://localhost:8080 reaches the container while the command runs. The first number is the local port, the second is the pod port.

Related Kubernetes (kubectl) shortcuts: Manage Resources

ShortcutActionNotes
kubectl apply -f [file]Apply resourceCreate/update resources from YAML.
kubectl delete pod [name]Delete podDelete a pod.
kubectl scale deploy [name] --replicas=3ScaleChange deployment replica count.
kubectl exec -it [pod] -- bashEnter podOpen bash shell inside a pod.
kubectl port-forward [pod] 8080:80Port forwardForward local port to pod port.
kubectl rollout restart deploy [name]Rolling restartRolling restart a deployment.

From the Kubernetes (kubectl) reference (17 entries) · all how-to answers