Solution to Error: ‘ssh: rejected: connect failed (Connection refused)’ using kubectl proxy
The error when accessing a service using kubectl proxy:
http://localhost:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/
Error: 'ssh: rejected: connect failed (Connection refused)'
Trying to reach: 'http://10.0.1.6:9090/'
This problems occurs if your Kubernetes Cluster’s Master version is incompatible to your kubectl’s version. Upgrading both to the latest version solves this problem.
Solution 1. Upgrade Kubernetes Cluster version
This depends on your Cloud Provider. In Google KubernetesEngine you can upgrade your Kubernetes Cluster in the Cluster Details page on https://console.cloud.google.com.
Solution 2. Upgrade kubectl version
sudo gcloud components update kubectl
Solution 3. Check requested/allocated resources in your Kubernetes Cluster
If your nodes do not have enough resources or there is a memory pressure on your node, then this error is thrown.
Check the requested/allocated resources in the Cluster Nodes page on https://console.cloud.google.com.