kubernetes: 1.6.1 The connection to the server localhost:8080 was refused

Kubernetes version v1.6.1

Environment:

  • arm64 cavium thunder x:
  • Ubuntu 16.04.2 LTS
  • 4.4.0-72-generic

What happened: init kubernetes with kubeadm init --kubernetes-version=v1.6.1 --pod-network-cidr=10.244.0.0/16 than tried kubectl taint nodes --all node-role.kubernetes.io/master- and got this The connection to the server localhost:8080 was refused - did you specify the right host or port?

or this

# kubectl apply -f https://github.com/coreos/flannel/raw/master/Documentation/kube-flannel.yml
The connection to the server localhost:8080 was refused - did you specify the right host or port?

or

# kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.1", GitCommit:"b0b7a323cc5a4a2019b2e9520c21c7830b7f708e", GitTreeState:"clean", BuildDate:"2017-04-03T20:44:38Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/arm64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 88
  • Comments: 49

Most upvoted comments

did you run below commands after kubeadm init

To start using your cluster, you need to run (as a regular user):

sudo cp /etc/kubernetes/admin.conf $HOME/ sudo chown $(id -u)😒(id -g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.conf

I didn’t have admin.conf
Did I miss something?

try run with sudo permission mode sudo kubectl....

Localhost:8080 is a commonly used port for accessing web servers running on the local machine. It allows developers to test their web applications locally without needing to deploy them to a remote server. In particular, port 8080 is often used as a secondary port for HTTP traffic, in addition to the default port 80, which may be used by other applications or services.

When a web server is running on localhost:8080, it can be accessed through a web browser by navigating to "http://localhost:8080/". This can be particularly useful for debugging purposes, as developers can test and iterate on their applications without having to worry about network latency or other external factors.

Overall, localhost:8080 is a valuable tool for web developers and is commonly used in the development process. However, it’s important to remember that it should not be used in production environments, as it is not secure and can expose vulnerabilities to potential attackers.

Reproduce the same error when doing a tutorial from Udacity called Scalable Microservices with Kubernetes https://classroom.udacity.com/courses/ud615, at the point of Using Kubernetes, Part 3 of Lesson.

Launch a Single Instance:

kubectl run nginx --image=nginx:1.10.0

Error:

Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

How I resolved the Error:

Login 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 Teminal

Proceeded With Work!!!

I having this issue. I can’t find admin.conf

admin.conf must come out of thin air.

DC/OS works much better out of the box this is as painful as any cloud console. YUCK!

if you are using minikube then try $ minikube delete then $ minikube start

did you run below commands after kubeadm init

To start using your cluster, you need to run (as a regular user):

sudo cp /etc/kubernetes/admin.conf $HOME/ sudo chown $(id -u)😒(id -g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.conf

Thanks,it worked!

http://localhost:8080/

@kopollo

http://localhost:8080/ -> http://localhost.support/:8080 ???

This looks like spam/fishing? Can someone remove this comment?

The problem I encountered is as follows:

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

Because slave node missing configuration file “config” Solution master:

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

slave : Copy files from remote master node , and rename to config

    mkdir -p $HOME/.kube/
    scp root@matet:/etc/kubernetes/admin.conf   $HOME/.kube/config

vim /etc/hosts 127.0.0.1 localhost modify to: 10.0.0.8 localhost

Hello All. Need your help. I have installed kubectl and minikube on my MAC but both are not working.

When I run minikube start I get an error “Segmentation fault: 11”

When I run kubectl get nodes I get an error “The connection to the server localhost:8080 was refused - did you specify the right host or port?”

Please can you help me fix this issue

@kensupermen @MSKPV @Rukeith

The admin.conf is generated when you run the init command and not the join command.

please help me while installing node i am getting this error The connection to the server localhost:8080 was refused - did you specify the right host or port?

If you’re using minikube, then you need to start the minikube and then it will be alright.

$ minikube start

Once it’s up and running, check the kubectl version

$ kubectl version

Hope this helps

on trying the command kubectl run --image=nginx nginx-app --port=80 --env=“DOMAIN=cluster”

I am getting the following error… what will be the reason

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

This happened to me because of my .kube/config file having wrong indentations (due to manual editing)

did you run below commands after kubeadm init

To start using your cluster, you need to run (as a regular user):

sudo cp /etc/kubernetes/admin.conf $HOME/ sudo chown $(id -u)😒(id -g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.conf

This should be moved into the docs no? MIssing in the setup AFAIK

To those that can’t find admin.conf, hopefully this is relevant to your flavor of Linux, but I typically use: updatedb locate admin.conf

I was able to find the file this way, hope it helps you as well!

until 1.8 kubelet.conf worked for me @Rukeith @jeffhoffman13 now this is missing for some reason…

This issue was that I was using root account, switched back to regular user and executed the command which fixed my issue.