SELinux Error: 'setenforce: SELinux is disabled' — Cause, Fix, and Troubleshooting Guide
Fix 'setenforce: SELinux is disabled': you cannot enforce at runtime when SELinux is disabled in config. Re-enable via /etc/selinux/config, relabel, reboot.
- #security
- #hardening
- #troubleshooting
- #linux
- #selinux
Stuck on this DevOps Security & Hardening error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
What this error means
You ran setenforce 1 to turn SELinux enforcement on, but SELinux is fully disabled (not merely permissive), so there is no policy loaded to switch into enforcing mode. setenforce only toggles between permissive and enforcing; it cannot revive a disabled SELinux at runtime.
setenforce: SELinux is disabled
The distinction matters: SELINUX=disabled unloads the policy entirely and stops labeling files, whereas permissive keeps the policy loaded and labels current but logs instead of blocks. Re-enabling from disabled requires a config change, a filesystem relabel, and a reboot.
How it manifests on the host
sudo setenforce 1returnssetenforce: SELinux is disabledand enforcement stays off.getenforceprintsDisabled.- A CIS/STIG scan flags SELinux as not enforcing.
sestatusshowsSELinux status: disabled.
System configuration causes
- Disabled in config.
/etc/selinux/confighasSELINUX=disabled(often a leftover from earlier troubleshooting). - Disabled on the kernel command line.
selinux=0is set in GRUB, overriding the config file. - Never labeled filesystem. Running disabled for a long time means files lack SELinux labels; enabling straight to enforcing would break the system without a relabel.
- Minimal/cloud image shipped with SELinux disabled by default.
Interrogating the host
# Current mode and config vs. runtime
sestatus
getenforce
grep -E '^SELINUX=' /etc/selinux/config
# Is it disabled on the kernel command line? (overrides config)
grep -o 'selinux=[01]' /proc/cmdline
getenforce returning Disabled (not Permissive) confirms the policy is unloaded, which is why setenforce refuses.
Remediation
Re-enabling safely is deliberate: go through permissive first, relabel, verify, then enforce.
1. Remove any kernel-level disable so config can take effect. Edit /etc/default/grub, delete selinux=0 (and enforcing=0) from GRUB_CMDLINE_LINUX, then rebuild:
sudo grep selinux /etc/default/grub
# remove selinux=0, then:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg # BIOS; use the EFI path on UEFI hosts
2. Set the config to permissive and force a full relabel on next boot:
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
sudo touch /.autorelabel
sudo reboot
The relabel applies correct contexts to every file (necessary after running disabled).
3. After reboot, confirm and review denials before enforcing:
getenforce # should now say Permissive
sudo ausearch -m avc -ts recent # collect what WOULD have been denied
4. Switch to enforcing once the AVC log is clean:
sudo setenforce 1
sudo sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config
Hardening the host
- Never jump straight from
disabledtoenforcingwithout a relabel — unlabeled files can make the system unbootable or lock out logins. - The kernel
selinux=0argument overrides/etc/selinux/config; check/proc/cmdlineif config edits seem ignored. - Use permissive mode to gather AVCs first; enforce only after the denials are understood and policy is adjusted.
- A relabel of a large filesystem can take a while on first boot — plan for the extra downtime.
Related system errors
- SELinux ‘avc: denied’ Error Guide
- SELinux Troubleshooting Without Permissive Mode
- CIS Benchmark Hardening for Linux Servers
Fixed it? Get 500 DevOps Security & Hardening & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Stuck on this? Start guided troubleshooting
Open an interactive diagnostic session with this error already loaded. Work a step-by-step plan, record what each check returns, land on a root cause, and export a clean incident summary — no account needed to start.
Did this fix your issue?
Solved it a different way?
Share the fix that worked for you — reviewed, then published to help the next engineer.
That looks like it may contain a secret (key, token, password, or connection string). Please remove it — a note with a detected secret can’t be published.
Thanks — that helps. Published notes appear after a quick review.
Trending errors this week
The error guides other engineers are actually reading right now.
- 1mount: wrong fs type, bad option, bad superblock
- 2Docker 'failed to set up container networking': Fix the Bridge and IP Pool
- 3Docker 'failed to create shim task': How to Fix the containerd Runtime Error
- 4Transport endpoint is not connected
- 5modprobe: FATAL: Module not found
- 6mount: wrong fs type, bad option, bad superblock
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.