If your WordPress website is showing an error like:
PHP Fatal error: require_once(/home/user/public_html/wordfence-waf.php):
failed to open stream: No such file or directory
It means Wordfence's Web Application Firewall (WAF) file is missing or corrupted. Below is a step-by-step guide to recreate it manually.
If using SSH, run:
nano /home/user/public_html/wordfence-waf.php
Or, if using cPanel File Manager, navigate to public_html/, click Create New File, and name it wordfence-waf.php.
Copy and paste this content into the newly created file:
<?php
// Wordfence Web Application Firewall
if (file_exists(__DIR__ . '/wp-content/wflogs/bootstrap.php')) {
include_once __DIR__ . '/wp-content/wflogs/bootstrap.php';
}
This file ensures Wordfence WAF loads correctly.
Run:
chmod 644 /home/user/public_html/wordfence-waf.php
chown www-data:www-data /home/user/public_html/wordfence-waf.php # For Apache
chown nginx:nginx /home/user/public_html/wordfence-waf.php # For Nginx
Now, restart your web server:
sudo systemctl restart apache2
or
sudo systemctl restart nginx
After recreating wordfence-waf.php, verify that wp-config.php correctly points to Wordfence WAF.
nano /home/user/public_html/wp-config.php
It should look like this:
define("WFWAF_LOG_PATH", '/home/user/public_html/wp-content/wflogs/');
if (file_exists(__DIR__ . '/wordfence-waf.php')) {
include_once __DIR__ . '/wordfence-waf.php';
}
If this section is missing, add it before the /* That's all, stop editing! */ line.
Save the file and exit.
Test your website again.
If Wordfence still does not work, reinstall it:
wp plugin deactivate wordfence
wp plugin delete wordfence
wp plugin install wordfence --activate
This will regenerate all necessary files, including wordfence-waf.php.
| Issue | Fix |
|---|---|
| Missing wordfence-waf.php | Create it manually and add correct code |
| File exists but not loading | Check wp-config.php and update paths |
| Permissions issue | Set chmod 644 and chown www-data:www-data |
| Wordfence corruption | Reinstall with wp plugin install wordfence |
Now Wordfence WAF should work properly again!