The kubectl client you’re using is trying to talk to a Minikube Kubernetes API server that speaks a different version of the API, and the API server is refusing the connection because of this incompatibility.

This mismatch happens because Minikube, when it starts, spins up a specific version of the Kubernetes control plane. Your kubectl client, however, is a separate binary that can be updated independently. When kubectl’s API version is too far ahead or behind the Minikube cluster’s API version, they can’t communicate.

Here are the common causes and how to fix them:

  1. kubectl is significantly newer than Minikube’s Kubernetes version.

    • Diagnosis: Run kubectl version --short. Look at the Client Version. Compare this to the Kubernetes version Minikube is running. You can find Minikube’s version by running minikube start --alsologtostderr -v=7 and looking for lines related to the control plane image tag or the Kubernetes version it’s initializing.
    • Fix: Downgrade your kubectl client to match Minikube’s version. For example, if Minikube is running v1.20.0 and your kubectl is v1.23.0, you need to download the kubectl binary for v1.20.0. You can download specific versions from the official Kubernetes release page.
    • Why it works: The Kubernetes API is generally backward-compatible, meaning newer clients can talk to older servers, but only within certain bounds. If the API changes significantly between versions, the older server won’t understand the newer client’s requests.
  2. Minikube’s Kubernetes version is significantly newer than your kubectl client.

    • Diagnosis: Same as above: kubectl version --short and minikube start --alsologtostderr -v=7.
    • Fix: Upgrade your kubectl client to match or be within one minor version of Minikube’s Kubernetes version. Download the appropriate kubectl binary from the official Kubernetes release page and ensure it’s in your system’s PATH.
    • Why it works: Newer API features or changes in the server’s API endpoints won’t be understood by an older client, leading to errors.
  3. You have multiple kubectl binaries in your PATH, and the wrong one is being picked up.

    • Diagnosis: Run which kubectl to see which kubectl executable is being used. Then, run ls -l $(which kubectl) to inspect its properties. If you have multiple versions installed, your shell’s PATH might be prioritizing an older or newer one than you intend.
    • Fix: Adjust your shell’s PATH environment variable to prioritize the desired kubectl binary. For example, if you have ~/bin/kubectl and /usr/local/bin/kubectl, and you want to use the one in ~/bin, ensure ~/bin appears earlier in your PATH. You can do this by modifying your .bashrc, .zshrc, or equivalent shell configuration file.
    • Why it works: The system executes the first kubectl binary it finds in the directories listed in your PATH. By ordering PATH correctly, you ensure the intended version is invoked.
  4. Minikube is using a local kubectl version that’s not your system’s default.

    • Diagnosis: Minikube can be configured to use a specific kubectl binary. Check your Minikube configuration by running minikube config get kubectl-path. If this is set, it might be pointing to an older or different kubectl than the one you’re running kubectl version on.
    • Fix: Unset this configuration if you want Minikube to use your system’s default kubectl, or point it to your desired kubectl binary. Run minikube config unset kubectl-path or minikube config set kubectl-path /path/to/your/preferred/kubectl.
    • Why it works: This explicitly tells Minikube which kubectl binary to use for its operations, overriding the system’s default PATH resolution.
  5. Minikube cluster hasn’t started correctly, and its API server is not yet available or is in an inconsistent state.

    • Diagnosis: Check the status of your Minikube cluster with minikube status. If it shows as stopped or not running, or if minikube logs shows errors during startup, this could be the issue.
    • Fix: Stop and restart Minikube: minikube stop followed by minikube start. If it continues to fail, try deleting and recreating the cluster: minikube delete followed by minikube start.
    • Why it works: A fresh start ensures the Kubernetes control plane components within Minikube are initialized correctly and the API server is listening on the expected port.
  6. Network issues or firewall blocking communication between kubectl and the Minikube API server.

    • Diagnosis: While less common for local Minikube, if you’re using a remote Minikube or have strict network configurations, try a simple curl to the Minikube API server’s health endpoint. You can find the API server address from kubectl cluster-info. For example, curl -k https://192.168.49.2:8443/healthz. If this fails, it indicates a network problem.
    • Fix: Ensure no local firewalls or network policies are blocking traffic on the port Minikube’s API server is using (typically 8443 or higher, often dynamically assigned). For most local Minikube setups, this is not an issue unless you’ve manually configured network restrictions.
    • Why it works: kubectl communicates with the Kubernetes API server over HTTP/S. If the network path is blocked, the connection will fail before kubectl can even send its version information.

After applying these fixes, you should be able to run kubectl get nodes or kubectl version without encountering version mismatch errors. The next error you might hit, if you haven’t fixed it already, is likely related to RBAC (Role-Based Access Control) permissions if your kubectl context is configured with a user that lacks necessary cluster-admin privileges.

Want structured learning?

Take the full Minikube course →