Search code examples
kuberneteskubectl

did you specify the right host or port? error on Kubernetes


I have followed the helloword tutorial on http://kubernetes.io/docs/hellonode/.

When I run:

kubectl run hello-node --image=gcr.io/PROJECT_ID/hello-node:v1 --port=8080

I get:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

Why does the command line try to connect to the localhost?


Solution

  • The issue is that your kubeconfig is not right. To auto-generate it run:

    gcloud container clusters get-credentials "CLUSTER NAME"
    

    This worked for me.