Error using kubectl (The connection to the server localhost:8080 was refused - did you specify the right host or port?)
Quote from moshe on 15/10/2020, 11:03 pmUser 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 commandssudo 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
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 commandssudo 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
Quote from moshe on 28/08/2022, 9:47 amFastest 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
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
Uploaded files: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