<p>I am trying to solve this problem below:</p>
<pre><code>kubectl version
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;18&quot;, GitVersion:&quot;v1.18.6&quot;, GitCommit:&quot;dff82dc0de47299ab66c83c626e08b245ab19037&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2020-07-15T16:58:53Z&quot;, GoVersion:&quot;go1.13.9&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
Unable to connect to the server: dial tcp 192.168.0.10:6443: i/o timeout
</code></pre>
<p>And i found answer on some stackoverflow post that i am trying to solve</p>
<pre><code>$kubectl config view 
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://192.168.0.10:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
</code></pre>
<p>And after that i wrote following command and got this below:</p>
<pre><code>$ kubectl config use-context docker-for-desktop
error: no context exists with the name: &quot;docker-for-desktop&quot;
</code></pre>
<p>And after that i'am running sudo docker ps and i get this picture below:</p>
<p><a href="https://i.stack.imgur.com/uuWku.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uuWku.png" alt="enter image description here" /></a></p>
<p>How can I solve the <code>Unable to connect to the server</code> error??</p>

<p><code>Unable to connect to the server: dial tcp 192.168.0.10:6443: i/o timeout</code></p>
<p>Above error means Kubernetes API Server which is supposed to listen on port <code>6443</code> is not running for issue in <code>kubeadm init</code> process. This can be verified by checking if a kube API Server container is running or not by <code>sudo docker ps | grep api</code></p>
<p>Disable swap and reboot machine</p>
<pre><code>sudo swapoff -a 
sudo sed -i '/ swap / s/^/#/' /etc/fstab
</code></pre>
<p>Uninstall and reinstall kubernetes by running below command</p>
<pre><code>sudo kubeadm reset -f
sudo kubeadm init
</code></pre>
<p>As a sidenote if you are trying kubernetes on a local system I suggest to use minikube or kind instead of kubeadm.</p>
