Forum Navigation
You need to log in to create posts and topics.

Error using kubectl (The connection to the server localhost:8080 was refused - did you specify the right host or port?)

User getting the following error while trying to run kubectl commands

kubectl -n kube-system get pods

Error using kubectl (The connection to the server localhost:8080 was refused - did you specify the right host or port?)

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

Resolution
The kubernets config file is missing in your home directory. To fix the problem, run these commands

sudo cp /etc/kubernetes/admin.conf ~/.kube/config

sudo chmod 755 ~/.kube/config

sudo chown <your_user_name> ~/.kube/config

sudo chhgrp <your_user_group> ~/.kube/config

Fastest way to resolve the error

The connection to the server 10.100.90.83:6443 was refused – did you specify the right host or port?

After reboot of your server

containerd config default | tee /etc/containerd/config.toml

sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml  
systemctl restart containerd
systemctl restart docker
systemctl restart kubelet
Uploaded files: