<p>i am trying to create a Kubernetes cluster with the intention of hosting a docker registry, but after installing kubectl (via homebrew on Mac) along with minikube i am getting <code>The connection to the server localhost:8080 was refused - did you specify the right host or port?</code> when i run <code>kubectl version</code> or any other commands. I have previously used the docker desktop app with Kubernetes so don't know if there is any config i need to replace?</p>
<p>I have discovered there is no context set in the kubectl config but if i run <code>kubectl config get-contexts</code> there is nothing there.</p>

<p><a href="https://discuss.kubernetes.io/t/the-connection-to-the-server-localhost-8080-was-refused-did-you-specify-the-right-host-or-port/1464/9" rel="nofollow noreferrer">This thread</a> mentions:</p>
<blockquote>
<p>That error should only come up if you have no contexts configured in your client.<br />
If you run <code>kubectl config view</code> and you get something like this:</p>
<pre><code>$ kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: &quot;&quot;
kind: Config
preferences: {}
users: []
</code></pre>
<p>Then no contexts are configured.</p>
</blockquote>
<p>And:</p>
<blockquote>
<p>Getting <code>kubectl</code> to run really depends on how you installed it.<br />
Basically, if you install and have a proper config file, it should always work.</p>
<p>So, either an old file from a previous installation is there or something silly like that (although usually difficult to spot).</p>
<p>Also, make sure the commands don’t fail (some on the post pasted that the step to copy the <code>kubectl config</code> failed). That is the way to authorize to the cluster, so it won’t never work if that step doesn’t work</p>
</blockquote>
<p>Example of possible resolution:</p>
<pre class="lang-bash prettyprint-override"><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
kubectl get nodes
</code></pre>
<p>(From &quot;<a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#more-information" rel="nofollow noreferrer">Creating a cluster with <code>kubeadm</code></a>&quot;)</p>
