Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes connection error in Mac

OS : OSX (mac)

Docker : 18.06.0-ce (edge)

Kubernetes : 1.10.3

I use Kubernetes for the first time.

I tried Google but could not find the manual for Kubernetes, which operates on the Mac.

Running kubectl version outputs The connection to the server localhost:8080 was refused - did you specify the right host or port?

like image 671
user10147267 Avatar asked Oct 21 '25 04:10

user10147267


1 Answers

I came across this issue when changing from minikube to the Docker Desktop supplied Kubernetes. For me, the issue was caused by a stale .kube configuration. Posting my workaround here as this was the first result I found on google when looking to troubleshoot the issue.

1. Uninstall Minikube

I had originally installed with homebrew: brew uninstall minikube. If installed using other methods, go back to your install source for uninstall info.

After minikube was uninstalled, I restarted my machine which may or may not have been necessary but it is what I did.

2. Disable Kubernetes in docker Desktop

  1. Open Docker Desktop preferences, click Kubernetes menu
  2. De-select 'Enable Kubernetes' checkbox. Click Apply & Restart

3. Remove old kube and minikube config

  1. Open terminal to your home directory.
  2. Check for settings directories: ls -al and look for .kube and .minikube.
  3. Remove .kube settings: rm -rf ./.kube.
  4. Remove .minikube settings: rm -rf ./.minikube.
  5. Confirm: ls -al and make sure the .kube and .minikube directories have been deleted.
  6. If everything looks good, close terminal.

4. Re-enable Kubernetes in Docker Desktop

  1. Open Docker Desktop preferences, click Kubernetes menu
  2. Select 'Enable Kubernetes' checkbox. Click Apply & Restart
  3. Open new terminal window and run kubectl version. You should see info for Client Version and Server Version if everything worked.
like image 157
Ryan McCormick Avatar answered Oct 22 '25 20:10

Ryan McCormick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!