<p>I have two clusters that are very different (one kubernetes 1.13 with dashboard 1.0 and created with kops in aws; the other uses kubernetes 1.14 with dashboard 2.0 and created with EKS) same issue for both, and I use kubectl 1.17 to interface with both. Once I start <code>kubectl proxy</code>, I can reach the dashboard I just installed via <strong>curl</strong>. Eg with the dashboard 2.0 in newer EKS cluster: </p>

<p>In one terminal:</p>

<pre><code>$ kubectl proxy 
Starting to serve on 127.0.0.1:8001
</code></pre>

<p>In another terminal</p>

<pre><code>$ curl http://127.0.0.1:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
&lt;!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--&gt;

&lt;!doctype html&gt;
&lt;html lang="en"&gt;

&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Kubernetes Dashboard&lt;/title&gt;
  &lt;link rel="icon" type="image/png" href="assets/images/kubernetes-logo.png"/&gt;
  &lt;meta name="viewport" content="width=device-width"&gt;
&lt;link rel="stylesheet" href="styles.d8a1833bf9631b49f8ae.css"&gt;&lt;/head&gt;

&lt;body&gt;
  &lt;kd-root&gt;&lt;/kd-root&gt;
&lt;script src="runtime.a3c2fb5c390e8fb10577.js" defer=""&gt;&lt;/script&gt;&lt;script src="polyfills-es5.ddf623b9f96429e29863.js" nomodule="" defer=""&gt;&lt;/script&gt;&lt;script src="polyfills.24a7a4821c30c3b30717.js" defer=""&gt;&lt;/script&gt;&lt;script src="scripts.391d299173602e261418.js" defer=""&gt;&lt;/script&gt;&lt;script src="main.a0d83b15387cfc420c65.js" defer=""&gt;&lt;/script&gt;&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>Clearly the dashboard service is reachable and responding to the request. The html is a bit different for the other cluster/dashboard combo but still no error.</p>

<p>However the exact same URL from chrome or firefox (running on the same host of course) gives me an error:</p>

<pre><code>This site can’t be reached
127.0.0.1 refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
</code></pre>

<p>The dashboard 2.0 itself seems happy: </p>

<pre><code>$ kubectl get all -n kubernetes-dashboard
NAME                                             READY   STATUS    RESTARTS   AGE
pod/dashboard-metrics-scraper-76679bc5b9-k7qjp   1/1     Running   0          136m
pod/kubernetes-dashboard-565688d4c4-dtw5w        1/1     Running   0          136m

NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/dashboard-metrics-scraper   ClusterIP   172.20.42.193    &lt;none&gt;        8000/TCP   142m
service/kubernetes-dashboard        ClusterIP   172.20.232.104   &lt;none&gt;        443/TCP    142m

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/dashboard-metrics-scraper   1/1     1            1           142m
deployment.apps/kubernetes-dashboard        1/1     1            1           142m

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/dashboard-metrics-scraper-6c554969c6   0         0         0       137m
replicaset.apps/dashboard-metrics-scraper-76679bc5b9   1         1         1       142m
replicaset.apps/kubernetes-dashboard-565688d4c4        1         1         1       142m
replicaset.apps/kubernetes-dashboard-56c5f95c6b        0         0         0       137m
</code></pre>

<p>Any ideas what is wrong? How is it possible that it works with curl and not a web browser? </p>

<p><strong><em>Updated info:</em></strong> </p>

<p>I checked ifconfig: </p>

<pre><code>$ ifconfig
eth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ...    
lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        ...
</code></pre>

<p>With the following kubectl proxy command, I can access dashboard in browser too: </p>

<p>In one terminal:</p>

<pre><code>kubectl proxy --address='172.17.0.2' --accept-hosts='.*'
</code></pre>

<p>Then chrome browser to <a href="http://172.17.0.2:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/" rel="nofollow noreferrer">http://172.17.0.2:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/</a> shows the login screen. </p>

<p>Both flags are necessary otherwise neither curl nor browser will work (the response is Forbidden if I don't use the <code>--accept-hosts</code> -- although that response is from the service so it is at least better than when using loopback). </p>

<p>Replacing by 127.0.0.1 by localhost does not help. I can reach the api server only if I used the full proxy command and <a href="http://172.17.0.2:8001/api" rel="nofollow noreferrer">http://172.17.0.2:8001/api</a>. </p>

<p>Does anyone know why chrome will not handle 127.0.0.1, whereas curl does, and why this accept-hosts is necessary when curling 172.12 IP but not when using 127 IP?</p>

<p>Well this is embarrassing but I figure I might as well leave this question and post an answer just in case someone else forgets the obvious: </p>

<p>I was shelled into a docker container running on my host when running the curl and kubectl proxy commands (I forgot! as it runs non-stop). The container shares the host's network which is why the 172.17 worked from the browser, but not the loopback. </p>

<p>If you setup the container to port-forward say port 8080 to 8080 (<code>docker ... -p 8080:8080 ...</code>) then the following proxy command (from inside that container) also works: </p>

<pre><code>$ kubectl proxy --port 8080 --address='0.0.0.0'
</code></pre>

<p>ie browsing to <a href="http://localhost:8080/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login" rel="nofollow noreferrer">http://localhost:8080/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login</a> on host works. </p>

<p>Sorry for the mistake!</p>
