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

so in this article we are going to read about how we can fix the error “The connection to the server localhost:8080 was refused – did you specify the right host or port” when try to run kubectl command.
in my case i am using AWS EKS managed service to setup my eks cluster, suddenly i am start getting error “The connection to the server localhost:8080 was refused – did you specify the right host or port” during multiple cluster creation operation.
{Read:- 5 Ways to Improve SEO on Your WordPress Site }
so for every kubectl command i am getting the same error.
i.e
{Read:- How to Build a WordPress Site in 1 Day }
- kubectl get pods
- kubectl get nodes
- kubectl get svc
How to fixed The connection to the server localhost:8080 was refused – did you specify the right host or port ?
Follow the below command to fix the issue
-
aws sts get-caller-identity
{Read:- 10 WordPress Mistakes to Avoid }
Amazon EKS uses the
aws eks get-token
command, available in version 1.16.156 or later of the AWS CLI or the AWS IAM Authenticator for Kubernetes withkubectl
for cluster authentication. If you have installed the AWS CLI on your system, then by default the AWS IAM Authenticator for Kubernetes will use the same credentials that are return -
aws eks –region us-west-2 update-kubeconfig –name eks-basic-cluster
in above command replace your region and cluster name, once you run above command you will get the confirmation message something like –
Added new context arn:aws:eks:us-west-2:XXXXXXXXXX:cluster/eks-basic-cluster to /home/ubuntu/.kube/config
- Now you are good to use any kubectl command.
{Read:- How to configure Horizontal Pod Autoscaler(HPA) in Kubernetes (EKS)? }