<p>I am trying to start Kubernetes with 'kubectl apply -f redis.yaml' and I am getting</p>
<pre><code>Unable to connect to the server: dial tcp: lookup MasterIP on 127.0.0.53:53: server misbehaving
</code></pre>
<p>Before, I was receiving</p>
<pre><code>The connection to the server localhost:8080 was refused - did you specify the right host or port?
</code></pre>
<p>This error. I was searching for the solution and someone said trying to use this command</p>
<pre><code>export KUBERNETES_MASTER=http://MasterIP:8080
</code></pre>
<p>After that, I am receiving the error above? How can I fix this?</p>
<pre><code>kubectl cluster-info

Kubernetes master is running at 192.168.219.107:6443 
KubeDNS is running at 192.168.219.107:6443/api/v1/namespaces/kube-system/services/
</code></pre>
<p>my ./kube/config</p>
<pre><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: 
    server: https://****:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: 
    client-key-data: 
</code></pre>

<p><code>export KUBERNETES_MASTER=http://MasterIP:8080</code> is not correct because the port should be <code>6443</code> and protocol should be <code>https</code> for external connection coming to Kubernetes API Server.</p>
<pre><code>export KUBERNETES_MASTER=https://MasterIP:6443`
</code></pre>
<p>You seem to have a valid <code>kubeconfig</code> file and so you really don't need to export <code>KUBERNETES_MASTER</code> environment variable.</p>
<p>Make sure that the file is located at <code>.kube/config</code> path in your <code>home</code> directory. otherwise point <code>KUBECONFIG</code> environment variable to the path where the <code>kubeconfig</code> file is located.</p>
