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

+3 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
• 18,520 points
26,710 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
• 52,350 points
Thanks that worked!
Glad to help. :)
i got error in second step :

cp: cannot stat '/etc/kubernetes/admin.conf': No such file or directory
Try running these commands,
mkdir ~/.kube
vim ~/.kube/config
and copy the config file from mster node to nodes config file.
This did not work for me

Try to restart your cluster. Or check the configuration file.

$ kubectl config view
thanks , it worked.
+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, 2019 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, 2019 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, 2019 by Sumit

Related Questions In Kubernetes

0 votes
1 answer

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

Hi@akhtar, You may get this error if Kubectl ...READ MORE

answered Jun 6, 2020 in Kubernetes by MD
• 95,460 points
41,218 views
0 votes
1 answer

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

Hi@akhtar, This error may occur because of network ...READ MORE

answered May 21, 2020 in Kubernetes by MD
• 95,460 points
4,275 views
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, 2019 in Kubernetes by DareDev
• 6,890 points
1,974 views
+2 votes
0 answers

The connection to the server localhost:8080 was refused

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

Aug 8, 2019 in Kubernetes by Lakshminarayanan
17,396 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17, 2019 in Others by anonymous
15,455 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,024 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
• 7,060 points
4,396 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP