How to fix running with swap on is not supported in Kubernetes

KubernetesBEGINNERHIGHUpdated Dec 5, 2025· 226 views

Kubernetes requires swap to be completely disabled on all cluster nodes before kubeadm can initialize. This error occurs during preflight checks when swap is detected on the system.

Quick fix

Fixes running with swap on is not supported

free -h
  1. Check current swap status
  2. Disable swap temporarily
  3. Disable swap permanently in fstab
  4. Verify fstab syntax is valid
kubernetes — error
free -h
running with swap on is not supported

What this error means

Kubernetes requires swap to be completely disabled on all cluster nodes (both control plane and worker nodes) before kubeadm can initialize the cluster. When kubeadm detects active swap during the preflight checks, it fails with this error because Kubernetes is designed to have full control over memory allocation. Allowing the operating system to use swap introduces unpredictability in pod memory management, performance degradation, and stability issues that compromise cluster reliability. The scheduler cannot account for swap memory when making pod placement decisions, and pods do not request swap space—only memory. Historically, swap was considered incompatible with Kubernetes because it makes memory limits behave unexpectedly and pods can experience performance penalties when pages are swapped to disk.

Typical symptoms

  • kubeadm init fails during preflight checks with [ERROR Swap]: running with swap on is not supported
  • kubelet process fails to start with exit code 1 and logs reference swap being enabled
  • kubeadm join fails on worker nodes with the same swap error during preflight phase
  • Cluster initialization appears to proceed but nodes fail to join or become NotReady state
  • Docker or containerd services start but kubelet refuses to run while swap is active
  • System passes other preflight checks but stops immediately on swap detection

Common causes

  1. Default Linux installation includes swap partition that was never disabled during OS setup
  2. Swap was configured in /etc/fstab for hibernation or system performance and remains enabled
  3. Swap was temporarily disabled with swapoff but changes not made persistent, so swap re-enabled after reboot
  4. Virtual machine or cloud instance template comes pre-configured with swap space enabled
  5. User manually created swap file or partition but did not update fstab configuration
  6. Systemd service or boot scripts re-enable swap after it was previously disabled
  7. Multiple swap devices or files exist and only one was disabled

How to fix "running with swap on is not supported"

1Check current swap status

Verify whether swap is currently enabled:

bash
free -h

If the Swap row shows a value greater than 0 in the "total" column, swap is enabled. You can also check with:

bash
swapon --show

Or view your fstab configuration:

bash
cat /etc/fstab

Look for any lines containing the word "swap" (not commented out with #).

2Disable swap temporarily

Disable swap immediately without rebooting:

bash
sudo swapoff -a

Verify swap is now disabled:

bash
free -h

The Swap row should now show 0 total. Note: This change is temporary and swap will re-enable on the next reboot unless you also modify /etc/fstab.

3Disable swap permanently in fstab

Comment out all swap entries in /etc/fstab to prevent swap from re-enabling on reboot:

bash
sudo sed -i '/ swap / s/^/#/' /etc/fstab

Verify the changes:

bash
cat /etc/fstab

All swap-related lines should now start with #. If you prefer manual editing:

bash
sudo nano /etc/fstab

Find lines containing "swap" and add # at the beginning.

4Verify fstab syntax is valid

After modifying /etc/fstab, check that the file syntax is correct:

bash
sudo mount -a

If no errors appear, the syntax is valid. Swap lines should look like:

bash
# /swapfile swap swap defaults 0 0

Note the # at the beginning indicating the line is commented out.

5Initialize kubeadm cluster

Now that swap is disabled, initialize your Kubernetes cluster:

bash
sudo kubeadm init --pod-network-cidr=10.244.0.0/16

Replace the pod-network-cidr with your desired network range if using a different CNI plugin. If the error persists, ensure:

1. All nodes (control plane and workers) have swap disabled
2. Run sudo swapoff -a if swap somehow re-enabled
3. Check for multiple swap devices with swapon --show

6Test persistence by rebooting

Confirm swap remains disabled across reboots:

bash
sudo reboot

After the system boots, verify swap is still disabled:

bash
free -h

Swap should show 0 total. Also verify your Kubernetes nodes are healthy:

bash
kubectl get nodes -o wide

All nodes should show status "Ready". If a node shows "NotReady" after reboot, check kubelet status:

bash
sudo systemctl status kubelet

Advanced notes

Kubernetes has evolved its swap support over recent versions. Starting with Kubernetes 1.22, alpha support for swap was introduced through the NodeSwap feature gate, allowing limited swap usage on a per-node basis. By Kubernetes 1.28, swap support on Linux nodes graduated to Beta status with significant improvements and cgroup v2 support.

However, swap support requires explicit feature gate activation and is not recommended for production clusters without thorough testing. The NodeSwap feature only supports cgroup v2 (not cgroup v1), and support is primarily for experimental or edge-case scenarios.

For a standard Kubernetes cluster, disabling swap remains the recommended and simplest approach. The pre-1.22 workaround of using --fail-swap-on=false flag is deprecated.

If swap must be used on Kubernetes 1.22+, enable the NodeSwap feature gate and configure memorySwap.swapBehavior (LimitedSwap is default).

Most production deployments should keep swap disabled to maintain predictable performance and avoid memory management complexities.

Frequently asked questions

What does "running with swap on is not supported" mean?
Kubernetes requires swap to be completely disabled on all cluster nodes (both control plane and worker nodes) before kubeadm can initialize the cluster. When kubeadm detects active swap during the preflight checks, it fails with this error because Kubernetes is designed to have full control over memory allocation. Allowing the operating system to use swap introduces unpredictability in pod memory management, performance degradation, and stability issues that compromise cluster reliability.
How do I fix "running with swap on is not supported"?
Kubernetes requires swap to be completely disabled on all cluster nodes before kubeadm can initialize. This error occurs during preflight checks when swap is detected on the system.
What causes "running with swap on is not supported"?
Default Linux installation includes swap partition that was never disabled during OS setup Swap was configured in /etc/fstab for hibernation or system performance and remains enabled Swap was temporarily disabled with swapoff but changes not made persistent, so swap re-enabled after reboot
Is the "running with swap on is not supported" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading