Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

when i am trying to test the configuration of kubectl

kubectl get svc 

i am getting this

error: the server doesn't have a resource type "svc"

when I try this command

kubectl get services 

i am getting error:

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

and i am following this userguide to deploy a kubernetes application on my mac

https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html#eks-create-cluster

Admins-MacBook-Pro:~ Harshin$ kubectl version --short --client
Client Version: v1.10.3
like image 280
Harshin_ Avatar asked Jul 01 '18 07:07

Harshin_


People also ask

How do you fix the connection to the server localhost 8080 was refused Did you specify the right host or port?

This is a common issue when you run the kubectl command or a similar command. In most cases, Kubernetes does not have the correct credentials to access the cluster. It can be easily resolved easily by setting an environment variable in most similar cases.

Why is localhost 8080 refused to connect?

The localhost simulates a web server running on your computer. When the “localhost refused to connect” error appears, it is likely due to misconfigured port. Other common reasons include insufficient permissions and the Apache webserver not running properly.

How do I fix localhost 8080?

You need to access your app with http in the URL not https when developing locally. You may have your web browser set to automatically try to upgrade the connection from http to https.


2 Answers

Make a copy of the config file and resolve this issue:

sudo mkdir ~/.kube sudo cp /etc/kubernetes/admin.conf ~/.kube/  cd ~/.kube  sudo mv admin.conf config sudo service kubelet restart 
like image 200
Hareesh R Avatar answered Sep 22 '22 03:09

Hareesh R


you need to specify kubeconfig for kubectl like this.

kubectl --kubeconfig .kube/config  get nodes
like image 26
sfgroups Avatar answered Sep 24 '22 03:09

sfgroups