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

Thanks worked for me… !

do it as a super user with sudo su , problem is KVM

If u have issue kubelet then this might help.
in my case, path of docker installation is causes the issue .
OS-ubuntu 20.04

1 . install docker through k8s guide (command - apt install docker.io does not install latest
version of docker and there can be issue in installation of containerd as well)
Install Docker Engine on Ubuntu | Docker Documentation – it install latest version of docker as well as containerd.
2. after installtion there will be /etc/containerd/config.toml file by default . just delete it
3. systemctl restart containerd
4. systemctl restart kubelet

Heyy @hemanth22 have your issue been resolved since i am also facing the same issue and would like to know how did you resolved it ?

Thanks, this solved problem for me too.

Our issue was due to the kubernetes certs expired.

To check the certs on the master: kubeadm alpha certs check-expiration

To renew the certs, see this link: Kubernetes certificates expired? Here's what you do now.

must be change parameter root >>>>to >>>> user
thanks

Hi all,
thanks for your kind postings here to help others out. I’m a newbie on Kubernetes and ran into difficulty with this error while using GCP . I followed some solutions here which open the path in solving my issue. this is what I did;

  1. sudo kubectl config view
    2.if output shows no context is set( see mrbobbytables posting Jan 2019) then use the next step to fix issues with kubectl config.

gcloud container clusters get-credentials CLUSTER_NAME \ --region=COMPUTE_REGION \ --project=PROJECT_ID

4. Make sure you insert your cluster name, compute region and project id. for more info visit https://cloud.google.com/kubernetes-engine/docs/troubleshooting.
Good luck!

Hi Guys, I am facing this issue while installing k8s v=1.26 and my os = centos7.

When I run the below command it is showing me the same error

kubeadm init --pod-network-cidr=10.244.0.0/16

when I am running Kubectl config view is showing the “null” values for cluster, users etc etc.

Can anybody help me how to fix this error?

Hi, I enabled Kubernetes in Docker Desktop and had the same problem. Because I use Docker Desktop for learning purposes and I had no data related to Kubernetes, I clicked Settings/Kubernetes/Reset Kubernetes Cluster. After reset the Docker Desktop indicates that Kubernetes is running in the left lower corner - green Kubernetes indicator. Now everything works as expected.

Guys, don’t use sudo for KUBECTL APPLY!!!

does anybody have idea how to fix if the same error occour using podman instead of docker?

You helped us a lot. Greetings from germany. We are students and you saved us. Kuss geht raus :slight_smile:

After I installed Rancher desktop I had the error ‘The connection to the server localhost:8080 was refused - did you specify the right host or port?’

To fix, I just needed to download Ubuntu and in Rancher Desktop go to ‘Preferences’- > ‘WSL’ select Ubuntu.

Issued resolved.

Also, when executing the kubectl get nodes command, using Linux Ubuntu for studies, I was experiencing this same error.

One way I managed to get past this error was to follow the steps below:

1-) kubectl config view (as mentioned above). When executing this command, the cluster and context fields were null and could not necessarily be set to any value);

2-) Use the sudo kind get clusters command to find out the name of the cluster;

3-) Use sudo kind get kubeconfig --name=“cluster-name” > ~/.kube/config (change cluster name)

4-) Validate with kubectl config view, the node will already be configured with the cluster and context;

5-) Run kubectl get nodes and finally, the name of the node will appear, with status, roles and version it is running;