Skip to content

CSF blocked my IP and locked me out of cPanel/WHM — clearing the deny

CSF or LFD blocked your own IP and now WHM, SSH, and the sites are unreachable. Here is how to tell a temporary block from a permanent one and remove it without making things worse.

CSF locking out the operator is one of the most common self-inflicted cPanel emergencies. A handful of failed logins, a noisy port scan from your office, a misconfigured monitoring script, or a too-strict rule and LFD adds your IP to the block list — after which WHM, SSH, and sometimes the hosted sites all go dark from your location. The good news: the block is almost always reversible in seconds if you can reach a shell. The trap is that the shell you would use is behind the same firewall.

What’s happening

CSF (ConfigServer Security & Firewall) blocks IPs in two distinct ways, and they clear differently. Temporary blocks are added by LFD (the login-failure daemon) when an IP trips a threshold — too many SSH/FTP/IMAP/WHM login failures, or a PORTFLOOD/CONNLIMIT trigger. These live in memory and expire on their own after TTL seconds. Permanent blocks are written to /etc/csf/csf.deny and persist across reboots and reloads until you remove the line. A third layer, GeoIP/CC_DENY or a manual deny, can block an entire country or range that your IP happens to fall into.

When you are locked out, every retry from the blocked IP can extend a temporary block or trip a fresh one, so hammering the login makes it worse. The reliable recovery path uses an access channel that bypasses the firewall: the provider’s serial/KVM console, a second already-allowed IP, or — if you planned ahead — an entry in csf.allow that LFD is forbidden to override.

How to verify

If you still have any shell (console, second IP, existing session), the first command tells you everything — whether your IP is blocked, by which mechanism, and why:

# The single most useful command — grep your IP across all CSF state
csf -g 203.0.113.10

That output names the source: a csf.deny line (permanent), a DENY temp entry with a countdown (LFD), or an csf.allow line (you are fine, look elsewhere). Confirm the reason in the LFD log:

# Why did LFD block it?  (login failures, port flood, etc.)
grep 203.0.113.10 /var/log/lfd.log | tail -20

# The permanent block list itself
grep 203.0.113.10 /etc/csf/csf.deny

# Live temporary blocks with their TTL
csf -t

Rule out a country/range block that swept your IP up, and confirm whether CSF is even in enforcing mode:

# Is your country denied wholesale?
grep -E '^CC_DENY|^CC_ALLOW' /etc/csf/csf.conf

# Is CSF live (enforcing) or in TESTING mode?
grep -E '^TESTING' /etc/csf/csf.conf
csf -l | head    # current iptables rules CSF installed

Blocked in csf.deny is a permanent line you must delete. A temp DENY with seconds remaining will clear itself but you can force it. TESTING = "1" means CSF flushes its rules every few minutes via cron — sometimes a lucky escape, but never the intended production state.

The fix

  1. Get a firewall-independent shell — if SSH itself is blocked, do not keep retrying. Open the provider’s serial/KVM console or boot a rescue shell. From there CSF is fully manageable even though the network is blocking you.
  2. Remove a permanent deny — for a csf.deny hit, run csf -dr 203.0.113.10. This deletes the line and reloads the rules. Editing /etc/csf/csf.deny by hand works too, but csf -dr also clears the matching in-memory rule so you do not have to reload separately.
  3. Clear a temporary block — for an LFD temp block, csf -tr 203.0.113.10 removes it immediately rather than waiting out the TTL. Use csf -tf only if you want to flush all temporary blocks at once.
  4. Allow-list your operator IP so it cannot be re-banned — the durable fix. Add your address with csf -a 203.0.113.10 "operator", which writes it to /etc/csf/csf.allow. Allow-listed IPs are exempt from LFD blocks, so a few mistyped passwords will never lock you out again. Keep this list tight — only known management IPs.
  5. Resolve a country/range block — if CC_DENY swept in your country, add your specific IP to csf.allow (which overrides CC_DENY), or reconsider whether blanket geo-blocking is worth the operator risk. Country blocks are blunt and routinely catch VPN exits and travelling staff.
  6. Find and fix what tripped LFD — the lfd.log reason matters. If it was login failures, fix the credential or key on your side before reconnecting. If it was PORTFLOOD/CONNLIMIT, a monitoring or sync script from your IP is too aggressive — exempt it in csf.allow or tune the trigger in csf.conf.
  7. Use TESTING mode as a safety net for risky changes — before editing rules that could lock you out, set TESTING = "1" in /etc/csf/csf.conf and csf -r. LFD’s lfd cron then flushes the firewall every few minutes, so a bad rule self-clears. Set it back to "0" once the change is proven, or the firewall is not actually protecting anything.
  8. Reload, then verify from the blocked location — after any change, csf -r to apply, then re-run csf -g 203.0.113.10 to confirm the IP is clear, and finally test the actual connection (SSH/WHM) from the location that was locked out — clearing the rule and confirming access are two separate steps.

The lasting fix is preparation: keep your management IPs in csf.allow and a console login on hand, so a CSF lockout is a thirty-second annoyance rather than a scramble. Stack Harbor maintains CSF rule sets and operator access under cPanel/WHM management — start a conversation if the firewall has you locked out.