Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2022-12-14T21:52:06.333Z
Answers: I have done this before but still my Kubernetes doesn't work.
Answers: best_of_man
Answers: CC BY-SA 4.0
Answers: 2022-12-15T08:37:49.550Z
Answers: ok. can you post your ```cat /etc/fstab``` and ```df``` outputs before do ```swapoff -a``` ?
Answers: igiannak
Answers: CC BY-SA 4.0
Answers: 2022-12-14T11:40:51.603Z
Answers: 2022-12-14T11:40:51.603Z
Answers: igiannak
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2022-12-22T22:28:06.070Z
Answers: 2022-12-22T22:28:06.070Z
Answers: Ralle Mc Black
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2022-12-14T11:39:02.700Z
Comments: 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.
Comments: igiannak
Tags: <kubernetes><kubectl>
Title: How to get ride of running "sudo swapoff -a" command everytime before running "kubectl" commands?
UserDisplayName: best_of_man
ThreadText: # 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>
  
  
  ---
  
  