<p>I want to run Kubernetes locally so I can try it out on a small Java program I have written.</p>
<p>I installed WSL2 on my Windows 11 laptop, Docker Desktop, and enabled Kubernetes in Docker Settings.</p>
<p>There are a number of SO questions with the same error but I do not see any of them regarding Windows 11 and Docker Desktop.</p>
<p>I open a terminal, type <code>wsl</code> to open a linux terminal. Then I issue the command:</p>
<pre><code>$ kubectl get pods
The connection to the server 127.0.0.1:49994 was refused - did you specify the right host or port?
</code></pre>
<p>but I see</p>
<p><a href="https://i.stack.imgur.com/PCJKa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PCJKa.png" alt="docker" /></a></p>

likejudo
<p>Using Docker Desktop and Kubernetes on Linux Ubuntu, I got the same error, but also with Docker Desktop being unable to start normally because <strong>I already had a Docker Installation</strong> on my machine, resulting in the <strong>docker context</strong> being set to the default Docker environment <strong>instead of the required Docker Desktop</strong>.</p>
<p>Confirm the following first:</p>
<ol>
<li><p><strong>Make sure <strong><a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/" rel="nofollow noreferrer">kubectl</a></strong> is correctly installed and ~/.kube/config file exists and is correctly configured on your machine</strong> because it holds the configuration of the cluster info and the port to connect to, which both are used by kubectl.</p>
</li>
<li><p>Check the context with</p>
<p><code>kubectl config view</code></p>
</li>
<li><p>If not set to current-context: docker-desktop, for example</p>
</li>
</ol>
<pre><code>   apiVersion: v1
   clusters:
   - cluster:
       certificate-authority-data: DATA+OMITTED
       server: https://kubernetes.docker.internal:6443
     name: docker-desktop
   contexts:
   - context:
       cluster: docker-desktop
       user: docker-desktop
     name: docker-desktop
   current-context: docker-desktop
   kind: Config
   preferences: {}
   users:
   - name: docker-desktop
     user:
       client-certificate-data: REDACTED
       client-key-data: REDACTED
</code></pre>
<p><strong>then Set the docker context to Docker Desktop on your machine</strong></p>
<p><code>kubectl config use-context docker-desktop</code></p>
<p>If that doesn't solve your issue maybe you have to check for <strong>specific Windows 11 Docker Desktop Kubernetes configuration/features</strong></p>
<p>Check also:
<strong><a href="https://docs.docker.com/desktop/faqs/windowsfaqs/" rel="nofollow noreferrer">Docker Desktop Windows FAQs</a></strong></p>
