kubectl connection to server was refused

  kuberenetes, linux
$ kubectl get all
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Possible fix:

sudo -i
swapoff -a
exit

$ kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   10m
Also disable your swap for good:
sudo vi /etc/fstab
and # comment the swap line
Restart the service:
sudo systemctl restart kubelet