Minikube: kubectl connection refused - did you specify the right host or port?

FrankSchulz picture FrankSchulz · Sep 15, 2017 · Viewed 8.7k times · Source

I try to run minikube v0.22.1 and kubectl v1.7.5 on MacOS with Virtualbox.

$ minikube start
Starting local Kubernetes v1.7.5 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.

$ minikube version
minikube version: v0.22.1

$ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

However all kubectl commands fail with "connection refused - did you specify the right host or port?"

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.5", GitCommit:"17d7182a7ccbb167074be7a87f0a68bd00d58d97", GitTreeState:"clean", BuildDate:"2017-08-31T19:32:26Z", GoVersion:"go1.9", Compiler:"gc", Platform:"darwin/amd64"}
The connection to the server 192.168.99.100:8443 was refused - did you specify the right host or port?

The solution proposed here (sudo ifconfig vboxnet0 up) did not help, the vboxnet0 interface is up.

Any ideas or suggestions are highly appreciated.

Answer

Tejas Pandit picture Tejas Pandit · Sep 17, 2017

If you run

kubectl config get-contexts

Do you get the following?

CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
*         minikube   minikube   minikube 

If not that means your kubectl context is not correctly setup. To setup the context correctly run this

kubectl config use-context minikube