Plugin how-tos · Guide
How to Set Up the Wordfence Firewall
Short answer
To set up the Wordfence firewall, install and activate the Wordfence Security plugin, let Learning Mode run for 7 days while you use your site normally, then set the firewall status to Enabled and Protecting. Next, run Optimize the Wordfence Firewall so the Protection Level reads Extended Protection, which loads the firewall before WordPress starts.
Key takeaways
- Learning Mode runs for 7 days on a new install and adds normal requests to the allowlist instead of blocking them.
- Extended Protection loads the firewall before WordPress starts, while Basic WordPress Protection loads it as a normal plugin.
- Free Wordfence users get new firewall rules 30 days after Premium users, as of November 2026.
- Free users can reach a maximum firewall rating of 64% on the Dashboard and 55% on the Firewall page.
- A blocked request shows a 403 Forbidden page that says a potentially unsafe operation was detected.
- Rate Limiting and Brute Force Protection are enabled by default and should stay on.
What does the Wordfence firewall do?
The Wordfence firewall is a PHP-based web application firewall that checks each request to your site and blocks requests that match known attack patterns.
Wordfence describes it as an application-level firewall that filters malicious requests before plugins or themes can run vulnerable code. Its help page lists 6 attack types it guards against: SQL injection, cross-site scripting, malicious file upload, directory traversal, local file inclusion, and external entity expansion. See the Wordfence firewall help page for the full list.
The firewall uses two kinds of rules. Some rules match known attacks seen in the wild, and generic rules use pattern matching to catch new attacks of a known type. Wordfence updates the rules from its servers without a plugin update, so new rules can arrive between releases.
Wordfence Security has more than 5 million active installs on WordPress.org, as of November 2026, and its scanner checks for more than 44,000 known malware variants. Those figures come from the Wordfence plugin page on WordPress.org.
What do you need before you start?
You need a WordPress administrator account, a current backup, and about 15 minutes of active work, plus 7 days for Learning Mode to finish.
Make a full backup before you change security settings. If the firewall blocks a normal part of your site, a backup lets you restore fast while you fix the rule. Read our guide on how to back up WordPress before you install anything.
You also need an email address that you check, because Wordfence sends security alerts by email. WordPress.org asks you to enter that address on the Wordfence options page after your first scan.
Install Wordfence only from the official WordPress.org plugin directory. Plugins listed there must follow the Detailed Plugin Guidelines, which require code to be kept as secure as possible. A closed plugin is a different problem, as explained in our guide on what happens when a plugin is closed on WordPress.org.
How do you install Wordfence and turn on the firewall?
Install and activate Wordfence from your WordPress dashboard, then run a first scan and add your alert email address.
Follow these steps in order:
- Go to “Plugins” then “Add New” in your WordPress dashboard.
- Search for “Wordfence Security”, then click “Install Now” and “Activate”.
- Open “Wordfence” then “Dashboard” and enter your email address for security alerts.
- Go to “Wordfence” then “Scan” and click “Start New Scan”.
- Work through any threats the scan lists, one by one.
- Open “Wordfence” then “Firewall” and check the firewall status at the top of the page.
The firewall starts at once after activation, but it starts in Learning Mode on a new install. That is normal, and the next section explains what it does during those 7 days.
On a WordPress multisite network, network activate Wordfence instead of activating it on one site. Wordfence then appears in the Network Admin menu, and its firewall and login rules apply to the whole network.
How do you switch the firewall to Extended Protection?
Run the firewall optimization, which changes the PHP setup so the firewall loads before WordPress or any other PHP file.
When you first install Wordfence, the Protection Level reads “Basic WordPress Protection”. In that mode the plugin loads as a normal plugin after WordPress loads, so some vulnerable code can run first. Extended Protection loads the firewall first, so it can block requests before WordPress starts.
Follow these steps:
- Look for the notice at the top of WordPress admin pages that asks you to optimize the firewall, then click “Click Here to Configure”.
- If you dismissed that notice, open “Wordfence” then “Firewall”, click “All Firewall Options”, and click “Optimize the Wordfence Firewall” under “Protection Level”.
- Keep the server setup Wordfence selects for you, unless you know it picked the wrong one.
- Download the backup copies of “.htaccess” and “.user.ini” when Wordfence offers them.
- Click “Continue” to finish the setup.
Wordfence changes the PHP setting named “auto_prepend_file” to load a file called “wordfence-waf.php” before other code. Depending on your server, it writes that setting in “.htaccess”, “.user.ini”, or “php.ini”. The PHP manual lists “auto_prepend_file” among the core php.ini directives.
Wait up to 5 minutes on some hosts for the change to take effect. Then open “Wordfence” then “Firewall” and confirm the Protection Level now reads “Extended Protection”. Wordfence gives the full procedure on its firewall optimization help page.
Some hosts need manual setup. On Kinsta, for example, Wordfence asks you to pick “Manual Configuration” and ask Kinsta support to set the “auto_prepend_file” path for your site. If your host blocks the automatic change, ask its support team to set that value.
What happens during Learning Mode?
Learning Mode runs for 7 days on a new install and learns which normal requests your site makes, so the firewall does not block them later.
While Learning Mode is active, Wordfence adds requests that look like attack patterns to the allowlist instead of blocking them. A request on the allowlist is treated as safe and will not be blocked, unless you remove it from the allowlist.
Your site is not protected from certain complex attacks while it is in Learning Mode. Brute Force Protection, Login Security, other blocking features, and the Real-Time IP Blocklist for Premium users stay active during that time. Wordfence states this plainly on its Learning Mode help page.
Use your site normally during the 7 days. The more features you use, the fewer false blocks you will see later:
- Write and publish posts and pages
- Change theme styles and plugin settings
- Add or remove widgets
- Write or moderate comments
- Use every feature of your other plugins
If you used all of your site features before the 7 days end, you can switch the status to “Enabled and Protecting” early. If you are not sure you covered everything, let Learning Mode run the full 7 days.
Do not use Learning Mode if your site was just hacked or is under attack right now. Set the firewall to “Enabled and Protecting” at once instead, and read our guide on how much malware cleanup costs if you need help cleaning the site first.
How do you check that the firewall is protecting your site?
Open the Firewall page and confirm the Protection Level reads Extended Protection and the status reads Enabled and Protecting.
Wordfence shows status circles that rate how protected you are. Gray circles mean the firewall is in Learning Mode or Disabled.
To reach a 100% rating, Wordfence lists 6 conditions: enable Rate Limiting and Advanced Blocking, enable all firewall rules, optimize the firewall, enable Brute Force Protection, enable Premium firewall rules, and enable the Real-Time IP Blocklist.
Free users cannot reach 100%. Wordfence states that free users can reach a maximum rating of 64% on the Dashboard page and 55% on the Firewall page, as of November 2026. That gap comes from Premium-only items such as real-time rules and the Real-Time IP Blocklist.
Also check Live Traffic for proof that blocking works. Go to “Wordfence” then “Tools” then “Live Traffic”, and filter the feed to “Blocked by Firewall”. Blocked visits appear there with the visitor IP, the time, and the reason for the block.
| Check | Where to see it | What it should say |
|---|---|---|
| Protection Level | Wordfence then Firewall | Extended Protection |
| Firewall Status | Wordfence then Firewall | Enabled and Protecting |
| Rate Limiting | Firewall then All Firewall Options | Enabled |
| Brute Force Protection | Firewall then All Firewall Options | Enabled |
| Blocked visits | Tools then Live Traffic | Blocked by Firewall entries appear |
How do you fix a page the firewall blocks by mistake?
Allowlist that exact request, after you confirm the action you were doing is safe.
A blocked visit shows a “403 Forbidden” page that says "A potentially unsafe operation has been detected in your request to this site".
That message means the firewall matched a rule, not that your site is down. It can also appear on safe actions when a plugin or theme sends data that looks like an attack pattern.
If you are logged in as an administrator and you see the block page, use the button on that page to allowlist the action. Only use that button when you are certain the action is safe. If a link sent by someone else triggers the message, do not allowlist it.
If you were not logged in, or a visitor reports the block, find the request in Live Traffic. Go to “Wordfence” then “Tools” then “Live Traffic”, filter by “Blocked by Firewall”, then click “Add param to firewall allowlist” on the blocked request.
You can also turn on Learning Mode for a short time, repeat the blocked action, then set the status back to “Enabled and Protecting”. Wordfence adds the needed parameters to the allowlist while Learning Mode is on. Remember to switch it back, or the firewall will keep adding requests to the allowlist.
How do you change rate limiting and brute force settings?
Leave Rate Limiting and Brute Force Protection on, and change them only from the Firewall Options page.
Open “Wordfence” then “Firewall” then “All Firewall Options”. In the “Rate Limiting” section, confirm “Enable Rate Limiting and Advanced Blocking” is on. That option is enabled by default, and it throttles crawlers and users who send too many requests.
In the same options page, confirm Brute Force Protection is on. It is also enabled by default, and it limits login attempts on your WordPress login form. Wordfence lists both settings among the conditions for a full protection rating.
Do not turn either setting off to fix a slow site. A slow login page or a blocked crawler is usually a sign that a limit is working, not a reason to remove it. If a real user is locked out, check Live Traffic first to see which rule blocked them.
What is the difference between the free and Premium firewall?
Both versions include the firewall, but Premium gets new rules at once while the free version waits 30 days.
Wordfence updates firewall rules from its servers as new threats appear. Premium users receive those rules in real time, and free users receive the same rules 30 days later. That 30-day gap is the main firewall difference, as of November 2026.
Premium also adds the Real-Time IP Blocklist, which blocks requests from IP addresses that are attacking other WordPress sites right now. Free users do not get that blocklist, and country blocking is also a Premium feature.
Version 9.1.1 was released on November 10, 2026, after version 9.1.0 on November 9, 2026. Version 9.1.0 added faster firewall rule updates for all users, free and Premium. Wordfence announced both releases on its Wordfence 9.1.0 blog post.
Wordfence is an endpoint firewall, so it runs inside WordPress on your own server. A cloud firewall filters traffic before it reaches your server, which is a separate layer. Compare the two approaches in our guide on Cloudflare Free vs Pro for WordPress before you add a second firewall.
| Feature | Free | Premium |
|---|---|---|
| Web application firewall | Yes | Yes |
| New firewall rules | 30 days later | Real time |
| Real-Time IP Blocklist | No | Yes |
| Country blocking | No | Yes |
| Maximum firewall rating | 55% on Firewall page | 100% when all items are on |
How do you turn the firewall off safely?
Turn it off only for a short test, then turn it back on as soon as the test ends.
Open “Wordfence” then “Firewall” then “Firewall Options”. Set “Web Application Firewall Status” to “Disabled” and click “Save Changes”. That is the normal way to stop the firewall from the dashboard.
If the dashboard will not load, you can set a constant instead. Add define('WFWAF_ENABLED', false); to “wp-config.php” below the line about “WP_DEBUG” for Basic WordPress Protection, or to “wordfence-waf.php” before the line that starts with “if” for Extended Protection.
To remove Extended Protection itself, open “Firewall Options”, find “Protection Level”, and click “Remove Extended Protection”. Wordfence will ask you to save backups first, then it removes its code from your server files. Wait up to 5 minutes for the change to take effect.
Do not leave the firewall off after a test. A disabled firewall stops blocking the attacks listed at the start of this guide, and you will not get an alert when a new attack arrives. Set a reminder to re-enable it before you close the dashboard.
What mistakes should you avoid?
The most common mistake is leaving the firewall in Learning Mode long after the first week, which leaves complex attacks unblocked.
Avoid these mistakes:
- Leaving Learning Mode on with no end date after you turn it on by hand, since manual Learning Mode does not expire on its own.
- Allowlisting every blocked request without checking what it was, which can let a real attack through later.
- Turning the whole firewall off to fix one blocked page, instead of allowlisting that one request.
- Skipping the “.htaccess” and “.user.ini” backups during optimization, which makes a bad change harder to undo.
- Skipping plugin updates after setup, since an old plugin can open a hole the firewall must then catch. Learn how to spot one in our guide on how to find abandoned WordPress plugins.
- Deleting “wordfence-waf.php” by hand, which can cause a 500 error when Extended Protection is still on. Remove Extended Protection from the Firewall Options page first.
Frequently asked questions
How long does it take to set up the Wordfence firewall?
The active work takes about 15 minutes: install the plugin, run a scan, add your email, and run the firewall optimization. Learning Mode then runs for 7 days while you use your site normally. After those 7 days you switch the status to Enabled and Protecting, so the full setup takes a week from start to finish.
Is the free version of the Wordfence firewall enough for a small site?
The free version includes the full firewall, the malware scanner, and brute force protection, which covers the basics for a small site. Its main limit is timing: new firewall rules arrive 30 days after Premium users get them. If your site handles payments or holds member data, that 30-day gap is worth weighing against the Premium price.
Why does Wordfence block my own admin actions?
Wordfence blocks actions that match an attack pattern, and some safe plugin or theme actions look like attacks. Saving custom code, editing forms, or submitting unusual characters can trigger a block. Use the allowlist button on the block page if you are logged in as an administrator and you are certain the action is safe.
Can I use Wordfence with a cloud firewall at the same time?
Yes, you can use both, because they work at different points. A cloud firewall filters traffic before it reaches your server, while Wordfence runs inside WordPress and knows which user is signed in. Keep both sets of rules in mind when you allowlist something, so a request blocked in the cloud is not blamed on Wordfence.
What should I do if I am locked out of my own site by Wordfence?
First check whether the block page mentions Wordfence and states a reason for the block. If it does, note that reason, then disable the firewall with the constant in wp-config.php or wordfence-waf.php if you cannot reach the dashboard. Re-enable the firewall after you fix the cause, and remove any bad allowlist entries you added while locked out.
Sources
- Wordfence Web Application Firewall (WAF) Wordfence
- Firewall Learning Mode Wordfence
- Optimizing The Firewall Wordfence
- Wordfence Security – Firewall, Malware Scan, and Login Security WordPress.org
- What’s New in Wordfence 9.1.0: Security News, Faster Rules and Smarter Alerts Wordfence
- Detailed Plugin Guidelines WordPress Developer Resources
- Description of core php.ini directives PHP
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
