Unable to connect to the server: dial tcp 127.0.0.1:45451: connectex: No connection could be made because the target machine actively refused it

Viewed 3483

I am a newbie to Kubernetes and trying to set up a cluster that runs Cassandra in my local machine. I have used kind to create a cluster that was successful. After that when I try to run kubectl cluster-info, I am getting the below error:

Unable to connect to the server: dial tcp 127.0.0.1:45451: connectex: No connection could be made because the target machine actively refused it.

On docker container ls, I could see the control-plane running on the container using the port as below:

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                       NAMES
1c4b6101b8ff        kindest/node:v1.18.2   "/usr/local/bin/entr"   3 hours ago         Up 2 hours          127.0.0.1:45451->6443/tcp   kind-cassandra-control-plane
625fee22e0e6        kindest/node:v1.18.2   "/usr/local/bin/entr"   3 hours ago         Up 2 hours                                      kind-cassandra-worker

Am able to view the config file by executing kubectl config view as below, which confirms the kubectl is able to read the correct config file:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://127.0.0.1:45451
  name: kind-kind-cassandra
contexts:
- context:
    cluster: kind-kind-cassandra
    user: kind-kind-cassandra
  name: kind-kind-cassandra
current-context: kind-kind-cassandra
kind: Config
preferences: {}
users:
- name: kind-kind-cassandra
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

UPDATE:

When I run netstat, I could see below as the active connections on 127.0.0.1

 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:2869
 TCP    127.0.0.1:5354
 TCP    127.0.0.1:5354
 TCP    127.0.0.1:27015
 TCP    127.0.0.1:49157
 TCP    127.0.0.1:49158
 TCP    127.0.0.1:49174

Any help is really appreciated. TIA

3 Answers

Try using this command

minikube start --driver=docker

I'd expect it to be possibly a kind issue, not kubernetes issue so I'd investigate this first. Please show the following:

  • Operating System
  • Docker Version and release ("docker for mac", "docker for windows" etc)
  • How exactly kind cluster was created, config file etc.
  • kind get nodes
  • Resources
    • Given Windows or Mac, how many resources allocated for docker
    • Given Linux, how many resources the machine has

Afterwards, I suggest to recreate the kind cluster.

I had a similar problem in Windows 10 with Hyper-V and minikube start --driver=docker was not enough. I had to:

  • uninstall minikube
  • remove .minikube folder from my user profile
  • reinstall minikube
Related