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

poiuytrez picture poiuytrez · Apr 15, 2016 · Viewed 91.5k times · Source

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?

Answer

Alan Wagner picture Alan Wagner · May 12, 2016

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.