Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 827
FrankSchulz Avatar asked Sep 15 '17 07:09

FrankSchulz


People also ask

How do you fix the connection to the server localhost 8080 was refused Did you specify the right host or port?

Install and Set Up kubectlUsing the right user fixed the issue for me. I set up the cluster using kops method in AWS. yes this is the exact solution to fix this issue.

How does kubectl connect to minikube?

By default, kubectl gets configured to access the kubernetes cluster control plane inside minikube when the minikube start command is executed. You can also alias kubectl for easier usage. Alternatively, you can create a symbolic link to minikube's binary named 'kubectl'.

What port does minikube run on?

Now you can use minikube to retrieve a URL that is accessible outside of the container. This URL will allow you to access the hello-app service that is running on port 8080 inside your cluster.


2 Answers

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
like image 103
Tejas Avatar answered Sep 21 '22 11:09

Tejas


You may have it stopped or saved for any reason. sometimes, after you enable/disable addons you may need to restart it.

1) Restart minikube VM, stop it

$ minikube stop 

2) Start it again, make sure you assign enough cpu/memory (the following is just an example of how to pass it, you need to adjust it based on available resources in your machine)

$ minikube start --memory=10000 --cpu 4 

If this didn't work out, you can do the following that will help you to know more about the underlying cause of problem:

Check minikube status and make sure the status is Running

$ minikube status 

Or, check minkube logs:

minikube logs

Finally, if you couldn't fix it, you may need to delete and start it from scratch

$ minikube delete && minikube start 

Ref: https://github.com/kubernetes/minikube/issues/1498

like image 39
Muhammad Soliman Avatar answered Sep 18 '22 11:09

Muhammad Soliman