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

+2 votes

I'm trying to create a simple service on kubernetes

kubectl create serviceaccount dashboard -n default

but it throws the following error

The connection to the server localhost:8080 was refused - did you specify the right host or port?
Sep 4, 2018 in Kubernetes by Hannah
• 17,060 points
4,513 views

4 answers to this question.

0 votes

Run the following command as a normal user

mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

answered Sep 4, 2018 by Kalgi
• 45,780 points
Thanks that worked!
Glad to help. :)
+1 vote

I had the exact same error when I was trying to create a cluster on GCP. This is how I got it sorted:

  • Log in to Google Cloud Platform
  • Navigate to Container Engine Google Cloud Platform, Container Engine
  • Click CONNECT on Cluster
  • Use login Credentials to access Cluster [NAME] in your Terminal
answered Apr 26 by Vinay
+1 vote

Try using --server to specify your master:

kubectl --server=16.187.189.90:8080 get pod -o wide
answered Apr 26 by Jobin
+1 vote

I was trying to get status from a remote system using ansible and I was facing the same issue.
I tried and it worked.

kubectl --kubeconfig ./admin.conf get pods --all-namespaces -o wide
answered Apr 26 by Sumit

Related Questions In Kubernetes

0 votes
1 answer

Kubernetes error: Did you speciy the right host or port

Try and auto generate your kubeconfig. Use: gcloud container ...READ MORE

answered Jan 9 in Kubernetes by DareDev
• 6,810 points
140 views
+1 vote
0 answers

The connection to the server localhost:8080 was refused

$ kubectl get svc The connection to the ...READ MORE

Aug 8 in Kubernetes by Lakshminarayanan
1,800 views
0 votes
2 answers

Not able to expose port 80 on the host, kubernetes ingress

I was facing the same error. The nginix ...READ MORE

answered Sep 11, 2018 in Kubernetes by Kalgi
• 45,780 points
96 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
3,352 views
+3 votes
1 answer
0 votes
2 answers

Error saying “Error from server (NotFound): the server could not find the requested resource”

official Documentation says: A client should be skewed ...READ MORE

answered Sep 19, 2018 in Kubernetes by Nilesh
• 6,920 points
1,267 views