kubectl : connection refused

6/21/2017

I am on the way of installing minkube 0.19.1 in Ubuntu 16.04 following the kubernetes documentation. As prerequisits I have installed kubectl and Oracle VirtualBox. When I check kubectl with kubectl version it gives following.

Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.6", GitCommit:"7fa1c1756d8bc963f1a389f4a6937dc71f08ada2", GitTreeState:"clean", BuildDate:"2017-06-16T18:34:20Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

But when I netstat the port to check the process it gives nothing for the results. I have setup Google cloud SDK as well.

I have searched and tried for many solutions inclusing this but was not able to resolve my issue.

Here are my gcloud config and info results.


$gcloud config list


[compute]
zone = asia-southeast1-a
[core]
account = userName@mail.com
disable_usage_reporting = False
project = sampleproject1990

$gcloud info


Google Cloud SDK [159.0.0]

Platform: [Linux, x86_64] ('Linux', 'userName', '4.8.0-54-generic', '#57~16.04.1-Ubuntu SMP Wed May 24 16:22:28 UTC 2017', 'x86_64', 'x86_64')
Python Version: [2.7.12 (default, Nov 19 2016, 06:48:10)  [GCC 5.4.0 20160609]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]

Installation Root: [/home/userName/products/google-cloud-sdk]
Installed Components:
  kubectl: []
  core: [2017.06.09]
  gcloud: []
  gsutil: [4.26]
  bq: [2.0.24]
  alpha: [2017.03.24]
System PATH: [PATH=/usr/lib/jvm/java-8-oracle/bin:/home/userName/bin:/home/userName/.local/bin:/usr/local/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/local/apache-maven-3.3.9/bin]
Python PATH: [/home/userName/products/./google-cloud-sdk/lib/third_party:/home/userName/products/google-cloud-sdk/lib:/usr/lib/python2.7/:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [False]
Kubectl on PATH: [/usr/local/bin/kubectl]

WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
  /usr/local/bin/kubectl

Installation Properties: [/home/userName/products/google-cloud-sdk/properties]
User Config Directory: [/home/userName/.config/gcloud]
Active Configuration Name: [my-configuration]
Active Configuration Path: [/home/userName/.config/gcloud/configurations/config_my-configuration]

Account: [userName@mail.com]
Project: [sampleproject1990]

Current Properties:
  [core]
    project: [sampleproject1990]
    account: [userName@mail.com]
    disable_usage_reporting: [False]
  [compute]
    zone: [asia-southeast1-a]

Logs Directory: [/home/userName/.config/gcloud/logs]
Last Log File: [/home/userName/.config/gcloud/logs/2017.06.21/12.39.23.391849.log]

git: [git version 2.7.4]
ssh: [OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016]

Can anyone tell me how I can fix this issue ?

-- Chamalee De Silva
kubectl
kubernetes
minikube

3 Answers

7/24/2017

I had similar issues with Minikube and virtualbox driver. Please ensure the interface to which the virtualbox is configured, is up . I did a sudo ifconfig vboxnet0 up and my issue got resolved

-- NSP
Source: StackOverflow

2/12/2019

I faced the same issue. Turns out that I was running the command without being the root user. So, if you login as the super user (sudo -i), it might work.

-- yadu
Source: StackOverflow

1/31/2018

This issue is because the Kubelet is not running or is not healthy.

One way to resolve this issue:

$ sudo swapoff -a
$ sudo systemctl enable kubelet
$ sudo systemctl start kubelet

After this, deploy Kubernetes with kubeadm as given below:

$ sudo kubeadm init --ignore-preflight-errors=all

After loading the kubeadm credentials, untaint the master node and join worker nodes if you are working on a cluster.

And now give the command:

$ sudo kubectl cluster-info

The server and the client should be running with the same Kubernetes version.

If this solution doesn't work, scrape Kubernetes, kubectl, kubeadm and kubelet and follow the Kubernetes installation steps alone from this guide.

-- Steffi Keran Rani J
Source: StackOverflow