[Solved] Unable to connect to the server: dial tcp: lookup with AWS EKS

0 min read 112 words

If you have received the following error while trying to issue commands to kubectl:

Unable to connect to the server: dial tcp: lookup

Then it may be due to your kube-config being out of date. You might just need to update the local kube-config.

How to update the local kube-config

Make sure to replace eu-west-1 with your cluster’s region, and replace cluster_name with the name of your EKS cluster.

aws eks --region "eu-west-1" update-kubeconfig --name "cluster_name"

How to update kube-config from Terraform state

aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)

The above code makes use of the Terraform state’s output from when you generated the cluster.

Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags