<p>I have deployed kubernetes cluster on AWS EC2 Ubuntu Nodes, one master node and one worker node. Its a free tier t2.micro machine with 1 CPU.</p>

<p>I installed and configured everything and on day 1 everything works fine. <code>kubectl get nodes</code> command was responding without any delay and i was able to create MYSQL deployment.</p>

<p>Next day when i tried <code>kubectl get nodes</code> i was getting <strong>The connection to the server :6443 was refused - did you specify the right host or port?</strong> and even sometimes i am getting <strong>Unable to connect to the server: net/http: TLS handshake timeout</strong></p>

<p>I checked the following things to verify whether kubernetes is working or not
<code>sudo systemctl status kubelet</code> it was in active status</p>

<p>Even its surprising that sometime <code>kubectl get nodes</code>  works perfectly and sometime it return <strong>The connection to the server :6443 was refused - did you specify the right host or port?</strong></p>

<p>I am not able to understand how to fix this issue ?</p>

<p>This could be caused by a mismatch between the actual master node IP (<code>apiserver</code>) and the <code>server</code> entry configured in your <code>~/.kube/config</code>. Verify that they both match and if not, just update the <code>server</code> entry.</p>

<p>Keep in mind that EC2 instances can and will fail (I've seen them randomly crashing even on managed clusters). This could explain why one day your control plane was accessible on one IP and no longer accessible on the next day.</p>
