Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Fixing "Failed Opening Required wordfence-waf.php" — Restore or Recreate the File

3 min read
11.04.2025

If your WordPress website displays the "Failed Opening Required wordfence-waf.php" error, it means the Wordfence Web Application Firewall (WAF) file is missing, corrupted, or has incorrect permissions. The closely related fatal-error and not-found variants are covered in Fixing wordfence-waf.php Fatal Error in WordPress and Fixing "wordfence-waf.php Not Found" Error in WordPress; for the manual recreate procedure, see How to Recreate wordfence-waf.php Manually in WordPress.

Fixing Wordfence wordfence-waf.php Error
"Failed opening required" — PHP can't reach the WAF bootstrap.
PHP Fatal error:  require_once(/home/user/public_html/wordfence-waf.php): 
failed to open stream: No such file or directory

indicates that Wordfence's Web Application Firewall (WAF) is missing or corrupted.

Check If wordfence-waf.php Exists

Run:

ls -lah /home/user/public_html/wordfence-waf.php

If the file does not exist, proceed to restore or recreate it.

Restore wordfence-waf.php from Backup

If you have a backup of your WordPress site, restore the wordfence-waf.php file from:

  • cPanel > File Manager
  • Your hosting provider's backup system
  • A manual backup (FTP, cPanel, SSH)

If the file is restored, restart Apache/Nginx:

sudo systemctl restart apache2

or

sudo systemctl restart nginx

Recreate wordfence-waf.php Manually

If the file cannot be restored, recreate it.

Create a New wordfence-waf.php

  1. Connect via SSH or use cPanel File Manager
  2. Create the file manually:
    nano /home/user/public_html/wordfence-waf.php
  3. Add the following content:
    <?php
    // Wordfence Web Application Firewall
    if (file_exists(__DIR__ . '/wp-content/wflogs/bootstrap.php')) {
        include_once __DIR__ . '/wp-content/wflogs/bootstrap.php';
    }
  4. Save the file (CTRL + X, then Y, then ENTER).

Set 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

Restart Apache/Nginx

sudo systemctl restart apache2

or

sudo systemctl restart nginx

Check & Update wp-config.php

If wordfence-waf.php is still missing, check your wp-config.php file.

  1. Open wp-config.php for editing:
    nano /home/user/public_html/wp-config.php
  2. Find this line (or add it if missing):
    define("WFWAF_LOG_PATH", '/home/user/public_html/wp-content/wflogs/');
  3. Save the file & exit.

Try loading your site again.

WordPress Hosting
The easiest WordPress installation in one click
  • One-click installation
  • Large template library
  • Visual page editor
  • SSL
WordPress Hosting

Reinstall Wordfence (If Necessary)

If Wordfence is still broken, reinstall it:

wp plugin deactivate wordfence
wp plugin delete wordfence
wp plugin install wordfence --activate

Now Wordfence WAF should work properly!

Summary of Fixes

Issue Fix
File missing Restore from backup or recreate manually
Permissions incorrect Set chmod 644 and chown 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 again!