k3s: The connection to the server localhost:8080 was refused - did you specify the right host or port?
morde last edited by
When I run any
kubectlcommands, I'm getting
The connection to the server localhost:8080 was refused - did you specify the right host or port?
This problem is likely caused by a bad
~/.kube/configperhaps you have a file from a different kubernetes install (minikube) or an older k3s. If the server is local you can fix this by running these commands,
mkdir ~/.kube sudo k3s kubectl config view --raw | tee ~/.kube/config chmod 600 ~/.kube/config
The contents of
~/.kube/configneed to have the same information as
/etc/rancher/k3s/k3s.yamlwhen the server was started (the keys, ip, and ports).
Note in order to tell k3s to use this config file https://devops.stackexchange.com/a/16044/18965 .
You should persist this by having it set in