Kubernetes error after restart – The connection to the server x.x.x.x:6443 was refused

Recently, I encountered the error “The connection to the server x.x.x.x:6443 was refused – did you specify the right host or port?” on my Kubernetes cluster installed locally on my spare Ubuntu laptop. The cluster has been working fine after initial configuration.

Running any of the Kubectl command for example Kubectl cluster-info was getting the same error message

Screenshot_from_2018-11-20_14-37-25

While there are tons of information available on the internet talking about all possible scenarios, but in my case, Swap memory was causing the issue on my laptop.

If you recall, we disable the swap memory by running “swapoff -a” command before installing the Kubernetes v1.8.0 and above. Typically, calls to swapon occurs in the system boot scripts making swap devices available if not disabled explicitly.

The Solution

The solution was to disable the swap from the /etc/fstab file. You can use any editor to comment out the /swapfile entry under the fstab file.

Screenshot_from_2018-11-20_14-46-51

Once commented, save the file and restart the machine. Running the Kubectl command after restart should get the expected result now.

Leave a comment