127.0.0.1:8001 refused to connect when kubectl proxy to access kubernetes dashboard

Majid Rajabi picture Majid Rajabi · Dec 9, 2018 · Viewed 8.6k times · Source

I deploy a cluster (neo4j) with kubeadm based on this guide. Now I have these pods :

NAME           READY   STATUS    RESTARTS   AGE
neo4j-core-0   1/1     Running   0          20h
neo4j-core-1   1/1     Running   0          20h
neo4j-core-2   1/1     Running   0          20h

and these services :

NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP             60d
neo4j        ClusterIP   None             <none>        7474/TCP,6362/TCP   20h
nginx        ClusterIP   None             <none>        80/TCP              25h

Then I install kubernetes dashboard :

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

So when I do kubectl proxy to access the dashboard, with below link, it says 127.0.0.1 refused to connect.

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/.

What should I do to access the dashboard?

I also create sample user following this guide.

Answer

coolinuxoid picture coolinuxoid · Dec 10, 2018

Kubernetes dashboard fully rely on Apiserver. Connection refused means there is an issue with communication with apiserver. Please see https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard---1.7.X-and-above#kubectl-proxy

Also you can try to run

kubectl proxy --address='0.0.0.0' --port=8002 --accept-hosts='.*'

And check if on other interface(port 8002) rather than 127.0.0.1 it works.