← All notes

kubectl port-forward tunnels a local port to a port on a Pod for debugging

Answer: kubectl port-forward TARGET LOCAL:REMOTE forwards a local port to a port on a Pod. The target can be a pod, or a deployment, replicaset or service that selects a matching pod. It is useful for database debugging.

Examples

kubectl port-forward pods/mongo-75f59d57f4-4nd6q 28015:27017
kubectl port-forward deployment/mongo 28015:27017
kubectl port-forward service/mongo 28015:27017
kubectl port-forward deployment/mongo :27017
kubectl port-forward pod/mypod 5000 6000
kubectl port-forward service/myservice 8443:https
kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000

What to expect

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Use Port Forwarding to Access Applications in a Cluster; kubernetes/website (GitHub), kubectl port-forward (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Use Port Forwarding to Access Applications in a Cluster; kubernetes/website (GitHub), kubectl port-forward (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.

Cite this

Permanent ID: iil:note:7904bhxq

iinventedlight. 2026. "kubectl port-forward tunnels a local port to a port on a Pod for debugging." iinventedlight Library, iil:note:7904bhxq, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-port-forward/. License: CC-BY-4.0.

@misc{iil_note_7904bhxq,
  author = {{iinventedlight}},
  title = {{kubectl port-forward tunnels a local port to a port on a Pod for debugging}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/kubernetes-port-forward/},
  note = {Permanent ID iil:note:7904bhxq. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-port-forward.md.