Kubernetes not starting on Docker Desktop for Windows

After enabling Kubernetes in Docker Desktop for Windows, it simply wouldn’t come up. I waited about an hour but nothing happened. All needed Docker images etc. were downloaded but then the process stalled.

After searching for errors in all the different log files I found a bunch of lines like the following in C:\Users\%USERNAME%\AppData\Roaming\Docker\log\vm\kubelet.log:

[026:09:01:30.415][I] E0126 09:01:30.415129    3471 reflector.go:138] k8s.io/client-go/informers/factory.go:134: Failed to watch *v1.Service: failed to list *v1.Service: Get "https://vm.docker.internal:6443/api/v1/services?limit=500&resourceVersion=0": dial tcp 192.168.65.4:6443: connect: connection refused

So, apparently the connection to https://vm.docker.internal:6443 could not be established.

I searched the web for solutions to this problem for quite a while, but finally came up with the reason myself: My antivirus software blocked access to the hosts file! Docker couldn’t create the needed entries in C:\Windows\System32\drivers\etc\hosts!

After allowing write access to hosts in the antivirus software and restarting Docker Desktop, the following entries were created and Kubernetes finally started successfully.

# Added by Docker Desktop
192.168.178.76 host.docker.internal
192.168.178.76 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

Leave a Comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax