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

0 votes

Hi Guys,

I am trying to run kubectl get pods command inside Docker conatiner. But it is showing me the below error.

jenkins@f3460123b771:/root/.kube$ kubectl get pods
The connection to the server localhost:8080 was refused - did you specify the right host or port?

How can I solve this error?

Jun 6, 2020 in Kubernetes by akhtar
• 38,260 points
41,614 views
I am getting this error on worker node, and Worker nodes are NotReady state

1 answer to this question.

+1 vote
Best answer

Hi@akhtar,

You may get this error if Kubectl command did not able to find your config file. So create one .kube folder and move your config file inside this folder. It will solve this error.

answered Jun 6, 2020 by MD
• 95,460 points

selected Dec 15, 2020 by akhtar
what is contain for Config file. where can I get it.

This config file contains the information of your Kubernetes cluster. Go to your Kubernetes master node and search .kube folder. There you can find your config file. Now You need to create .kube folder in your docker container. After that copy the config file from Master node to .kube folder in your docker container.

0 votes

you just need to kill kubelet service and restart again. pods and container will be running as well as before reboot.

pkill kubelet

systemctl restart kubelet

good luck

answered Apr 3, 2021 by mehrdad

edited Mar 5
0 votes
The connection to the server localhost:8080 was refused - did you specify the right host or port?
answered Sep 19, 2022 by keerthi

edited Mar 5

Related Questions In Kubernetes

+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,618 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
2,253 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
• 52,350 points
2,293 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,936 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,248 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,504 views
0 votes
2 answers

Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error"

mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo ...READ MORE

answered Sep 30, 2020 in Kubernetes by Muhammad Badi uz Zaman
45,544 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