<p>OS : OSX (mac)</p>

<p>Docker : 18.06.0-ce (edge)</p>

<p>Kubernetes : 1.10.3</p>

<p>I use Kubernetes for the first time.</p>

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

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

<p>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.</p>
<h3>1. Uninstall Minikube</h3>
<p>I had originally installed with homebrew: <code>brew uninstall minikube</code>. If installed using other methods, go back to your install source for uninstall info.</p>
<p>After minikube was uninstalled, I restarted my machine which may or may not have been necessary but it is what I did.</p>
<h3>2. Disable Kubernetes in docker Desktop</h3>
<ol>
<li>Open Docker Desktop preferences, click Kubernetes menu</li>
<li>De-select 'Enable Kubernetes' checkbox. Click Apply &amp; Restart</li>
</ol>
<h3>3. Remove old kube and minikube config</h3>
<ol>
<li>Open terminal to your home directory.</li>
<li>Check for settings directories: <code>ls -al</code> and look for <code>.kube</code> and <code>.minikube</code>.</li>
<li>Remove <code>.kube</code> settings: <code>rm -rf ./.kube</code>.</li>
<li>Remove <code>.minikube</code> settings: <code>rm -rf ./.minikube</code>.</li>
<li>Confirm: <code>ls -al</code> and make sure the <code>.kube</code> and <code>.minikube</code> directories have been deleted.</li>
<li>If everything looks good, close terminal.</li>
</ol>
<h3>4. Re-enable Kubernetes in Docker Desktop</h3>
<ol>
<li>Open Docker Desktop preferences, click Kubernetes menu</li>
<li>Select 'Enable Kubernetes' checkbox. Click Apply &amp; Restart</li>
<li>Open new terminal window and run <code>kubectl version</code>. You should see info for Client Version and Server Version if everything worked.</li>
</ol>
