Kubernetes kubectl error: Unable to connect to server

10/10/2018

I am trying to run minikube on my local machine and get an error from kubectl.

The error message is: Unable to connect to the server: dial tcp 192.168.2.15:8443: connectex: No connection could be made because the target machine actively refused it.

Please see screenshot below.

enter image description here

I have tried all recommendations in Unable to run Kubernetes (kubectl) and Minikube on windows 10. Unable to connect to the server: dial tcp [::1]:8080: connectex: without any luck.

Any ideas for a fix?

UPDATE:

  1. Install was done following the instructions on https://kubernetes.io/docs/tasks/tools/install-minikube/
  2. Hyper-V was installed on my Win 10 machine
  3. Installed kubernetes-cli/kubectl using Chocolatey
  4. Downloaded minikube-installer.exe and ran it
  5. Created virtual switch with Hyper-V manager
  6. Started cluster with

    minikube start --vm-driver hyperv --hyperv-virtual-switch "myswitch"

After connection issue I tried:

  1. Disable dynamic memory on minikube VM
  2. Disable IPv6 protocal
  3. Set KUBECONFIG env variable
  4. Restart minikube

Output from minikube status and minikube ip:

enter image description here

-- Ewald Stieger
kubectl
kubernetes
minikube

1 Answer

10/11/2018

I hardly see any issues with your steps. If your IP address is 192.168.2.xxx, then everything should be fine. You have an external Virtual Switch, you installed minikube with Choco which is working out of the box, and you used the correct commands to start the minikube.

The only thing that seems suspicious is your step 4:

  1. Downloaded minikube-installer.exe and ran it

In some cases, this part can cause some conflicts, but be aware that this is just a guess based on experience. My advice is to remove the minikube completely and to try again. We will try to troubleshoot further if the problem persists. I've written an answer in which I explained all the steps on how to do it on Windows (out of my personal experience) in this topic, and here are the steps:

  1. Uninstall minikube-installer.exe from 'add/remove programs'
  2. Usually regular minikube stop, minikube delete does not work so you might have to turn off the minikubeVM in Hyper-V manually, then go to c:\users\%username%** and delete **.kube and .minikube.
  3. cuninst minikube
  4. Restart and install again as specified in the minikube documentation:

choco install minikube

choco install kubernetes-cli

Hopefully, this will help, as those are the steps I use when there is anything wrong with my minikube (tested on several Windows laptops).

-- aurelius
Source: StackOverflow