Unable to connect to the server: dial tcp i/o time out

When i run the kubectl version command , I get the following error message.

kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp 192.168.99.100:8443: i/o timeout

How do I resolve this?


Solution 1:

You can get relevant information about the client-server status by using the following command.

kubectl config view 

Now you can update or set k8s context accordingly with the following command.

kubectl config use-context CONTEXT-CHOSEN-FROM-PREVIOUS-COMMAND-OUTPUT

you can do further action on kubeconfig file. the following command will provide you with all necessary information.

kubectl config --help

Solution 2:

You have to run first

minikube start

on your terminal. This will do following things for you:

 Restarting existing virtualbox VM for "minikube" ...
⌛  Waiting for SSH access ...
📶  "minikube" IP address is 192.168.99.100
🐳  Configuring Docker as the container runtime ...
🐳  Version of container runtime is 18.06.3-ce
⌛  Waiting for image downloads to complete ...
✨  Preparing Kubernetes environment ...
🚜  Pulling images required by Kubernetes v1.14.1 ...
🔄  Relaunching Kubernetes v1.14.1 using kubeadm ... 
⌛  Waiting for pods: apiserver proxy etcd scheduler controller dns
📯  Updating kube-proxy configuration ...
🤔  Verifying component health ......
💗  kubectl is now configured to use "minikube"
🏄  Done! Thank you for using minikube!

Solution 3:

If you use minikube then you should run, kubectl config use-context minikube If you use latest docker for desktop that comes with kubernetes then you should run, kubectl config use-context docker-for-desktop

Solution 4:

I was facing the same issue on Ubuntu 18.04.1 LTS.

The solution provided here worked for me.

Just putting the same data here:

  1. Get current cluster name and Zone:

    gcloud container clusters list

  2. Configure Kubernetes to use your current cluster:

    gcloud container clusters get-credentials [cluster name] --zone [zone]

Hope it helps.

Solution 5:

I had the same issue when I tried use kubrnetes installed with Docker. It turned out that it was not enbled by default. enter image description here

First I enabled kubrnetes in Docker options and then I changed context for docker-for-desktop

kubectl config get-contexts
kubectl config use-context docker-for-desktop

It solved the issue.