Couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused

You need to start minikube first

command:
minikube start

and then try it again

1 Like

Thanks this solution works

Thank you so much… It helped
on Master node its working

When upgrading k8s from 1.24.1 to 1.25.1, the API server fails to start, with an error of “connection refused on port 6443”.

The following command let you do kubectl with no root user.

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

If you do it with root user, need configure like below:

export KUBECONFIG=/etc/kubernetes/admin.conf

Second root config overwrite the first no-root config. You will get the error when using no-root user to do kubectl. So don’t config the root one if you want to use no-root user.
Also, when you run like kubectl apply. Don’t use sudo when only no-root user is configured. You will also get the error because you are trying to do it as root.

I have the same issue , and i soved this use command below:

export KUBECONFIG=$HOME/.kube/config

Thank you so much @Alex_Ivan. It worked.

That is the solution! Thanks.

I encountered the same issue. While the kubectl get nodes command worked properly on the master1 node of my Kubernetes cluster, running kubectl get nodes on master2 and master3 nodes showed the same error you described.

I later identified the root cause:
During the TLS Bootstrapping configuration phase, we had only performed the following steps on the master1 node:

[root@k8s01 ~]# cd && mkdir -p /root/.kube  
[root@k8s01 ~]# cp /etc/kubernetes/admin.kubeconfig /root/.kube/config  

To fix this, I copied the admin.kubeconfig file from master1 to master2 and master3 using the following commands:

[root@k8s01 ~]# scp /etc/kubernetes/admin.kubeconfig root@dk2.docker.net:/root/.kube/config  
[root@k8s01 ~]# scp /etc/kubernetes/admin.kubeconfig root@dk3.docker.net:/root/.kube/config  

After this, the kubectl get nodes command immediately worked on both master2 and master3 nodes.