Blugh: oc unable to connect

I was hit with the most random error when trying to interact with an OpenShift cluster via command line: “Unable to connect to the server: dial tcp 192.168.39.5:8443: connect: no route to host”.

OpenShift cli client cannot connect

I had some issues once when working with OpenShift where the oc cli tool would throw the error shown above. After some failed googling, I managed to figure it out and decided to put it here to save someone else five minutes of their life.

If you’re seeing something like this, it may be because you have an abandoned minikube instance configured on your machine. The oc cli tool detects the .minikube directory in the HOME directory and if found will attempt to connect to the configured minikube machine ip instead of the configured openshift cluster.

Stopping and cleaning up minikube will resolve this!

eg.

minikube stop
minikube delete