<p>I'm running a k8 cluster on Docker for Mac. To allow a connection from my database client to my mysql pod, I use the following command <code>kubectl port-forward mysql-0 3306:3306</code>. It works great, however a few hours later I get the following error <code>E0201 18:21:51.012823   51415 portforward.go:233] lost connection to pod</code>.</p>

<p>I check the actual mysql pod, and it still appears to be running. This happens every time I run the <code>port-forward</code> command. </p>

<p>I've seen the following answer here: <a href="https://stackoverflow.com/questions/47484312/kubectl-port-forwarding-timeout-issue">kubectl port forwarding timeout issue</a> and the solution is to use the following flag <code>--streaming-connection-idle-timeout=0</code> but the flag is now deprecated. </p>

<p>So following on from there, It appears that I have to set that parameter via a kubelet config file (<a href="https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/" rel="noreferrer">config file</a>)? I'm unsure on how I could achieve this as Docker for Mac runs as a daemon and I don't manually start the cluster. </p>

<p>Could anyone send me a code example or instructions as to how i could configure <code>kubectl</code> to set that flag so my port forwarding won't have timeouts?</p>

<p>Port forwards are generally for short term debugging, not “hours”. What you probably want is a NodePort type service which you can then connect to directly.</p>
