<p>I'm trying to access minikube dashboard from host OS (Windows 10).</p>
<p>Minikube is running on my virtual machine Ubuntu 20.04 server.</p>
<p>The host is Windows 10 and I use VirtualBox to run my VM.</p>
<p>These are the commands I ran on Ubuntu:</p>
<pre><code>tomas@ubuntu20:~$ minikube start
* minikube v1.22.0 on Ubuntu 20.04 (vbox/amd64)
* Using the docker driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Updating the running docker &quot;minikube&quot; container ...
* Preparing Kubernetes v1.21.2 on Docker 20.10.7 ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
  - Using image kubernetesui/dashboard:v2.1.0
  - Using image kubernetesui/metrics-scraper:v1.0.4
* Enabled addons: storage-provisioner, default-storageclass, dashboard
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use &quot;minikube&quot; cluster and &quot;default&quot; namespace by default

tomas@ubuntu20:~$ kubectl get po -A
    
Command 'kubectl' not found, but can be installed with:
    
sudo snap install kubectl

tomas@ubuntu20:~$ minikube kubectl -- get po -A
NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE
kube-system            coredns-558bd4d5db-9p9ck                     1/1     Running   2          72m
kube-system            etcd-minikube                                1/1     Running   2          72m
kube-system            kube-apiserver-minikube                      1/1     Running   2          72m
kube-system            kube-controller-manager-minikube             1/1     Running   2          72m
kube-system            kube-proxy-xw766                             1/1     Running   2          72m
kube-system            kube-scheduler-minikube                      1/1     Running   2          72m
kube-system            storage-provisioner                          1/1     Running   4          72m
kubernetes-dashboard   dashboard-metrics-scraper-7976b667d4-r9k7t   1/1     Running   2          54m
kubernetes-dashboard   kubernetes-dashboard-6fcdf4f6d-c7kwf         1/1     Running   2          54m
</code></pre>
<p>And then I open another terminal window and I run:</p>
<pre><code>tomas@ubuntu20:~$ minikube dashboard
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
* Opening http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
  http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
</code></pre>
<p>Now on my Windows 10 host machine I go to web browser type in:</p>
<pre><code>http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
</code></pre>
<p>But I get error:</p>
<pre><code>This site can’t be reached 127.0.0.1 refused to connect.
</code></pre>
<p>How can I access minikube dashboard from my host OS web browser?</p>

<h2>Reproduction</h2>
<p>I reproduced this behaviour on Windows 10 and ubuntu 18.04 LTS virtual machine running using <code>VirtualBox</code>.</p>
<p>I have tried both <code>minikube drivers</code>: docker and none (last one means that all kubernetes components will be run on localhost) and behaviour is the same.</p>
<h2>What happens</h2>
<p>Minikube is designed to be used on localhost machine. When <code>minikube dashboard</code> command is run, minikube downloads images (metrics scraper and dashboard itsefl), launches them, test if they are healthy and then create proxy which is run on <code>localhost</code>. It can't accept connections outside of the virtual machine (in this case it's Windows host to ubuntu VM).</p>
<p>This can be checked by running <code>netstat</code> command (cut off some not useful output):</p>
<pre><code>$ minikube dashboard
🔌  Enabling dashboard ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
👉  http://127.0.0.1:36317/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

$ sudo netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     
tcp        0      0 127.0.0.1:36317         0.0.0.0:*               LISTEN      461195/kubectl
</code></pre>
<h2>How to resolve it</h2>
<p>Once <code>minikube dashboard</code> command has been run, kubernetes dashboard will remain running in <code>kubernetes-dashboard</code> namespace.</p>
<p>Proxy to it should be open manually with following command:</p>
<pre><code>kubectl proxy --address='0.0.0.0' &amp;
</code></pre>
<p>Or if you don't have <code>kubectl</code> installed on your machine:</p>
<pre><code>minikube kubectl proxy -- --address='0.0.0.0' &amp;
</code></pre>
<p>It will start a proxy to kubernetes api server on port <code>8001</code> and will serve on all addresses (it can be changed to default Virtual box NAT address <code>10.2.0.15</code>).</p>
<p><strong>Next step</strong> is to add <code>port-forwarding</code> in VirtualBox.
Go to your virtual machine -&gt; settings -&gt; network -&gt; NAT -&gt; advanced -&gt; port-forwarding</p>
<p>Add a new rule:</p>
<ul>
<li>host IP = 127.0.0.1</li>
<li>host port = any free one, e.g. I used 8000</li>
<li>guest IP = can be left empty</li>
<li>guest port = 8001 (where proxy is listening to)</li>
</ul>
<p>Now you can go to your browser on Windows host, paste the URL, correct the port which was assigned in <code>host port</code> and it will work:</p>
<pre><code>http://127.0.0.1:8000/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
</code></pre>
<h2>Useful links:</h2>
<ul>
<li><a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#proxy" rel="nofollow noreferrer">kubectl proxy command</a></li>
<li><a href="https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/" rel="nofollow noreferrer">Kubernetes dashboard</a></li>
</ul>
