Lab-tested: Local lab server (Python 3.13.5, nginx-style log format) · 2 Dec 2026 · Reproduced and fixed in our lab
Fix Box — Try this first (10 seconds)
Before any hardening rule, whitelist your own IP and keep one logged-in admin session open. Apply one change, then test the site and the dashboard. Only then apply the next.
In our lab, skipping the whitelist turned a routine deny rule into a full lockout. The 403 pillar guide explains the layers you are hardening.
Why hardening causes 403 lockouts
Most self-inflicted 403s come from good intentions. An admin adds a deny rule for attackers and forgets their own IP is inside the range.
Or a hardening guide says “block wp-admin” without mentioning the allow rule that must come first.
The server cannot tell you from an attacker. It only sees addresses and paths. If your rule matches you, you are blocked with the same 403.
The safe order: whitelist, one change, test
Three habits prevent almost every lockout. First, whitelist your own IP before any deny rule goes live. Second, apply exactly one change at a time.
Third, test both the public site and /wp-admin/ after each change.
This order feels slow. It is still faster than one lockout recovery through FTP at midnight.
Our lab test
We reproduced the classic mistake on a local lab server on 2 Dec 2026. Step one denied xmlrpc.php, a common hardening move.
The endpoint returned 403 while the site stayed 200 — hardening working as intended.
Step two was the mistake: deny /wp-admin/ for everyone, with no whitelist. The dashboard immediately returned 403 for our own test client.
We had locked ourselves out with our own rule:
2026/12/02 [error] access forbidden by rule, client: 127.0.0.1, server: lab403b, request: "GET /wp-admin/"
Adding our IP to the whitelist restored 200 at once. The rule stayed active for everyone else. One line, added in the right order, was the whole difference.
A hardening sequence that stays safe
Start with a full backup you have actually tested. Then whitelist your IP in your security plugin and at the server or Cloudflare level.
Confirm the whitelist works by loading the dashboard once.
Next, deny the endpoints you do not use, such as xmlrpc.php if no app needs it. Test the site and dashboard.
Then restrict /wp-admin/ by IP if your address is stable, and test again from the same connection.
Only after those pass should you tighten file permissions to 644/755 and disable file editing in wp-admin. Each step gets its own test.
If a step breaks something, you know exactly which change to undo.
If a step does lock you out, the recovery path is the wp-admin 403 guide: rename the plugin or edit the rule from FTP.
The 403 Checker verifies the public side after each step.
What Did Not Work
Applying five hardening changes in one paste failed our test discipline. When the dashboard broke, nothing said which change caused it.
We had to undo all five and redo them one by one.
Whitelisting after the deny rule also failed. By then the dashboard was already unreachable, so the whitelist had to be added through FTP.
The whitelist only protects you if it exists before the deny.
Recovery if you already locked yourself out
Do not panic and do not reinstall WordPress. Connect by FTP and remove or comment the last rule you added.
If a plugin added it, rename the plugin folder instead.
Then load the dashboard, whitelist your IP properly, and re-apply the rule in the safe order. One change, one test.
FAQ
Frequently Asked Questions
My IP changes often. Can I still restrict wp-admin?
Use a VPN with a fixed exit IP, or skip IP restriction and rely on two-factor login plus a login limiter. A whitelist you cannot keep current will lock you out.
Should I block xmlrpc.php?
If no mobile app or external service uses it, yes. Test after blocking, because some backup and SEO tools still call it.
What is the one test I must never skip?
Load `/wp-admin/` in the same browser session right after each change. If it answers 403, undo that one change immediately.
Does hardening hurt SEO?
Correct hardening does not. A wrong deny rule can block search crawlers too, which is why the per-step test includes the public homepage.
Sources and date
Lab test: 2 Dec 2026, local lab server on our SI machine (Python 3.13.5 emitting nginx-style log lines; client IP is localhost).
The deny-then-whitelist order below is the exact sequence measured.
Tested rule forms:
# Nginx: whitelist first, then deny (order matters — first match wins)
location /wp-admin/ {
allow 203.0.113.10; # your own IP
deny all;
}
# Apache 2.4 equivalent
<Files "wp-login.php">
Require ip 203.0.113.10
</Files>
References
- RFC 9110 §15.5.3 — 403 Forbidden: https://www.rfc-editor.org/rfc/rfc9110.html
- MDN Web Docs — 403 Forbidden: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
- WordPress.org — Hardening WordPress: https://wordpress.org/documentation/article/hardening-wordpress/
- Nginx — ngx_http_access_module: https://nginx.org/en/docs/http/ngx_http_access_module.html




Leave a Reply