Port forwarding dies after cancelling a TCP request #1620
Labels
kind/bug
Categorizes issue or PR as related to a bug.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
I use
kubectl port-forward
to forward traffic to a service and sometimes the service is not reachable anymore. After some investigation it looks like the port forwarding cannot handle with cancelled TCP requests and the port-forwarding locks up and showed the following error message:The
kubectl
process keeps running, but the port-forwarding is dead. Restartingkubectl port-forward
brings the service back alive.I have created a very basic application (in Go) that serves a 32MiB file and it can be invoked using
curl -o /dev/null http://localhost:8080
and it will complete the download. When runningcurl http://localhost:8080
, it will cancel the download after the request, because it won't display binary data. This application works fine locally.When run in Kubernetes and using
kubectl port-forward server 8080:8080
it works fine when files are downloaded, but it locks up when a download is cancelled. It looks likekubectl
is still accepting requests on port 8080, but doesn't seem to be able to contact the pod anymore.I tested with both Kubernetes v1.30 (using a single node Kind cluster) and in Kubernetes v1.29 using AKS (MS Azure). A full ready-to-run reproduction is available on https://github.com/ramondeklein/k8s-portforward-bug.
The text was updated successfully, but these errors were encountered: