microk8s Connection to port 16443 was refused

14.5k views Asked by At

I'm getting following error message:

root@master-1:~# microk8s.kubectl get no
The connection to the server 127.0.0.1:16443 was refused - did you specify the right host or port?

Even microk8s.kubectl cluster-info dump fails with message above. When I run microk8s start it still the same.

4

There are 4 answers

4
hejkerooo On BEST ANSWER

iptables were provisioned by ansible which were messing with microk8s iptables configuration

2
Wytrzymały Wiktor On

It is hard to tell exactly what might went wrong here but there are few things that you could do in order to fix your issue:

  • .kube/config is missing or not configured correctly. Create or copy a valid kubeconfig file to solve this.

  • You have swap not turned off. With swap enabled, kubelet service will not start. Execute: sudo swapoff -a in order to make sure it is disabled.

  • kubelet might be down. Check kubelet logs and make sure that kube-apiserver is up and running.

  • Check which ports are appropriate to use with the telnet command.

2
Алексей С On

check your /etc/ hosts file there should be these lines

127.0.0.1 localhost 127.0.1.1 name you servers

0
Ali On

For me Ubuntu 20.04.4 LTS (Focal Fossa), this two commands save my day:

sudo microk8s.refresh-certs --cert ca.crt

and

sudo microk8s.refresh-certs --cert server.crt