debug

kubectl proxy

Runs a local HTTP proxy that authenticates as your kubeconfig user and forwards requests to the Kubernetes API server. Useful for exploring the raw API with curl or serving the dashboard behind localhost auth.

kubectl proxy [--port=PORT] [--address=IP] [--www=DIR] [flags]

Common flags

Flag Purpose
-p, --port Local port to listen on (default 8001; 0 picks a random free port).
--address Local address to bind (default 127.0.0.1).
--accept-hosts Regex of Host headers the proxy will accept.
--api-prefix Prefix to serve the API under (default /).
--www Serve static content from this directory alongside the API.
--disable-filter Disable request filtering (risky - allows non-local hosts).

Examples

kubectl proxy --port=8001

Reach the API at http://localhost:8001/api/v1/...

curl http://localhost:8001/api/v1/namespaces/default/pods

List pods via the raw REST API through the proxy.

kubectl proxy --www=./dashboard --www-prefix=/ui/

Serve static files at /ui/ alongside the API.

Gotcha

Anyone who can reach the local port inherits your cluster credentials - never bind to 0.0.0.0 unless you know what you are doing.

Related commands

← All kubectl commands · Docker vs Kubernetes