If you're facing an issue where Wordfence WAF (wordfence-waf.php) is missing or inaccessible, follow these steps to download, restore, and fix file permissions.
If wordfence-waf.php is missing, you can manually download or recreate it.
wordfence-waf.php inside the wordfence directory.public_html/ using FTP, cPanel, or SSH.If you can't download the file, you can create it manually.
Run:
nano /home/user/public_html/wordfence-waf.php
or use cPanel File Manager > Click Create File > Name it wordfence-waf.php.
<?php
// Wordfence Web Application Firewall
if (file_exists(__DIR__ . '/wp-content/wflogs/bootstrap.php')) {
include_once __DIR__ . '/wp-content/wflogs/bootstrap.php';
}
Save & Exit (CTRL + X, then Y, then ENTER).
After restoring or recreating wordfence-waf.php, ensure it has the correct permissions.
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
chmod -R 755 /home/user/public_html/wp-content/wflogs
chown -R www-data:www-data /home/user/public_html/wp-content/wflogs
sudo systemctl restart apache2
or
sudo systemctl restart nginx
If wordfence-waf.php isn't loading, ensure the correct path is set in wp-config.php.
nano /home/user/public_html/wp-config.php
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 missing, add it before:
/* That's all, stop editing! Happy publishing. */
Save and exit.
Reload your website and check if the error is resolved.
If the issue persists, reinstall Wordfence:
wp plugin deactivate wordfence
wp plugin delete wordfence
wp plugin install wordfence --activate
This will regenerate wordfence-waf.php automatically.
| Issue | Fix |
|---|---|
| Missing wordfence-waf.php | Download from Wordfence or manually create it |
| Incorrect file permissions | Set chmod 644 and chown www-data:www-data |
| Permissions issue on wflogs/ | Set chmod -R 755 and chown -R www-data:www-data |
| Wrong wp-config.php settings | Add define("WFWAF_LOG_PATH", ...) |
| Wordfence corrupted | Reinstall with wp plugin install wordfence |
Now Wordfence WAF should be working correctly!