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
• 14,080 points
1,474 views

4 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 35,750 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,520 points
58 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
• 35,750 points
42 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
470 views
+3 votes
1 answer
0 votes
4 answers

Error saying "Unable to connect to the server: x509: certificate signed by unknown authority"

Append kubectl get all command with --insecure-skip-tls-verify=true This did ...READ MORE

answered Apr 23 in Kubernetes by Joshua
1,833 views
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,900 points
103 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.