My kubectl suddenly stopped working. Any commands results in "no route to host".

For example, getting logs kubectl logs mypod-746cfd667b-tdrnt

Error from server: Get "https://hades:10250/containerLogs/default/mypod-746cfd667b-tdrnt/mypod": dial tcp connect: no route to host

That's no wonder, because my server is located at, and for some reason, it is going to Why?

  • I tried removing kubectl (with purge) and reinstalling it. No difference.
  • I tried deleting the ~/.kube folder. No difference.
  • I CAN manage my cluster using Kubernetes Lens, which uses the same ~/.kube/config file. However, when trying to get the logs it fallbacks to using kubectl and I get the same issue.
# ping hades

PING hades ( 56(84) bytes of data.
64 bytes from hades ( icmp_seq=1 ttl=64 time=0.199 ms

Any idea how I can force kubectl to refresh its DNS cache?

Any idea how I can force kubectl to use a specific IP address, bypassing the DNS entirely?

My ~/.kube/config file is below. Note that "hades" isn't even mentioned anywhere.

apiVersion: v1
- cluster:
    certificate-authority-data: <<<long secret string>>>
  name: microk8s-cluster
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
- name: admin
    token: <<<short-secret-string>>>

1 Answer 1


The issue isn't on this machine at all. When making calls such as 'logs', kubectl contacts the node which in turns looks up which ip it should talk to. In this case, the node has a faulty /etc/hosts file with the last digit 2 dropped:


All that is needed is to ssh into the machine and update the hosts file there. There never was an issue on the client machine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.