<p>In order to disable the swap to a Linux machine, you have to elevate with root and edit <code>/etc/fstab</code>.<br />
From there, remove the swap entry by commenting it out. <br />
Upon reboot, swap will not mount.</p>

CC BY-SA 4.0
2022-12-14T21:52:06.333Z
I have done this before but still my Kubernetes doesn't work.
best_of_man
CC BY-SA 4.0
2022-12-15T08:37:49.550Z
ok. can you post your ```cat /etc/fstab``` and ```df``` outputs before do ```swapoff -a``` ?
igiannak
CC BY-SA 4.0
2022-12-14T11:40:51.603Z
2022-12-14T11:40:51.603Z
igiannak
<p>This error is not only related to the swapfile.</p>
<p>It comes also as soon you join an additional node and you dont have a network fabric installed.</p>
<p>Like flannel <a href="https://github.com/flannel-io/flannel" rel="nofollow noreferrer">https://github.com/flannel-io/flannel</a></p>

CC BY-SA 4.0
2022-12-22T22:28:06.070Z
2022-12-22T22:28:06.070Z
Ralle Mc Black
<p>It seems I must run <code>sudo swapoff -a</code> command everytime I want to run <code>kubectl</code> commands because if I don't do that it gives me such a following error:</p>
<pre><code>The connection to the server 192.168.1.2:6443 was refused - did you specify the right host or port?
</code></pre>
<p>Is there a way to do that permanently and getting ride of always running <code>sudo swapoff -a</code> command?</p>

CC BY-SA 4.0
2022-12-14T11:39:02.700Z
Do you have enabled the swap to the kubernetes Master nodes and worker nodes?
If I remember correctly, one of k8s installation requirements is to disable the swap to the nodes.
igiannak
<kubernetes><kubectl>
How to get ride of running "sudo swapoff -a" command everytime before running "kubectl" commands?
best_of_man
# How to get ride of running "sudo swapoff -a" command everytime before running "kubectl" commands?

(Asked by: username_0 on 2022-12-11)

It seems I must run sudo swapoff -a command everytime I want to run kubectl commands because if I don't do that it gives me such a following error:
The connection to the server 192.168.1.2:6443 was refused - did you specify the right host or port?

Is there a way to do that permanently and getting ride of always running sudo swapoff -a command?

**Tags:** kubernetes, kubectl

> **Comments:**
> **username_1**: Do you have enabled the swap to the kubernetes Master nodes and worker nodes? If I remember correctly, one of k8s installation requirements is to disable the swap to the nodes.  

---

## 2 answers

### Answer by username_1 on 2022-12-14. Score: 1

In order to disable the swap to a Linux machine, you have to elevate with root and edit `/etc/fstab`.  
From there, remove the swap entry by commenting it out.   
Upon reboot, swap will not mount.

> **Comments:**
> **username_0**: I have done this before but still my Kubernetes doesn't work.  
> **username_1**: ok. can you post your ```cat /etc/fstab``` and ```df``` outputs before do ```swapoff -a``` ?  

---

### Answer by username_2 on 2022-12-22. Score: 0

This error is not only related to the swapfile.

It comes also as soon you join an additional node and you dont have a network fabric installed.

Like flannel <https://github.com/flannel-io/flannel>


---

