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

This error occurs when kubectl is not able to connect to a Kubernetes cluster. Check that the cluster is up and running and that the kubectl configuration is pointing to the correct cluster.