The connection to the server localhost:8080 was refused

Hi Team,

Recently I started learning Kubernetes, and I am following k8’s course. I have created a aws instance and installed Kubernetes in that instance. When I try to execute the kubectl apply command or other commands like kubectl get pods I am getting below error.
“The connection to the server localhost:8080 was refused - did you specify the right host or port?”
Can you help me to fix this error.
Thanks in advance !!.

Hi @nagavardhan.awsdevop!

looks like kubectl is trying to connect to your local machine: localhost:8080 was refused. In order to connect to your AWS instance, you’ll have to configure kubectl with the right credentials.

How exactly did you install Kubernetes on AWS? Are you using Amazon EKS, or did you get an EC2 instance where you installed it manually?

Hi @HerrSubsetm,

I have created Ubuntu EC2 instnace in Aws, through putty I am connecting that one. Using below doc i have installed.

If it is trying to connect to my local machine, how do i set this port?

Is this the same problem which you posted about here? Server localhost:8080 was refused - #4 by HerrSubset

Hi @HerrSubset
Yes, same problem.

Then maybe close this thread if you can, I posted some pointers in the other topic.