My scans don't finish. What would cause that?

From Wordfence Documentation
Jump to: navigation, search

The following solutions have worked for some users:

Check your Wordfence version

First make sure you are running the newest version of Wordfence.

Adjusting the max execution time

Go to wordfence “options” page
Scroll to the bottom Set “Maximum execution time for each scan stage” to 15 seconds. Don’t forget to “Save”.
Try another scan.
If the scan does not complete, try this instead:
Go to the Wordfence Tools page, click the Diagnostics tab, and scroll to the bottom of the page.
Click the link to view your system's configuration.
Look for max_execution_time
Set the “Maximum execution time for each scan stage” to about 80% of that value. So if it’s 90, try setting the option to 75.
Try another scan and see if that works.

Explanation: Wordfence scans run for a few seconds up to several minutes. Most web servers don’t allow processes that run for several minutes. So the way we get around that is that we start a scan, and then after “Maximum execution time for each scan stage” we pause the scan and launch another process and pick up where we left off. We try to auto-detect what the max execution time should be for your server, but sometimes we get it wrong. So we've added this advanced config parameter to allow you to tell us how long a process should be allowed to run on your server.
When you set this value, you must make sure it’s not greater than the maximum execution time that PHP allows. That is the value set in “max_execution_time”. If your web host has set an Apache config variable that limits process execution time or if they have a “killer daemon” that kills long running processes, you also need to make sure that your “Max execution time” is shorter than the max process time that these allow.
However, you don’t want to set this value too low because it will increase load on your server as Wordfence pauses and restarts every time it hits the time limit. So the trick is to find a happy medium. Often this seems to be around 15 seconds, so try that first.

Handling memory errors

If you see an error about running out of memory, you can try the following:

  • Go to the Wordfence Options page.
  • Scroll toward bottom where you’ll see an option to specify the maximum memory that Wordfence uses.
  • Try increasing this to 300 Megabytes (the default is 256 megs)
  • Do another scan.
  • If you still get an out of memory error, try increasing by another 50 and re-scan.
  • You can keep increasing by 50 megabytes, but be careful that your web server does not run out of memory, because this may cause the operating system to behave unpredictably. You can refer to your web host’s documentation to find out what the maximum memory is that you’ve been allocated.

Additional memory limits and other limits you may not see

Some hosts limit memory across multiple processes, or may have CPU usage limits over a period of time. These limits are not always obvious since they may not cause error messages in your logs, and may make the scan appear to just stop working.

PHP 7 has substantial performance improvements in both memory and CPU usage, compared to any of the 5.x versions, so switching to a newer PHP version may help in these cases. Many hosts allow you to choose your preferred PHP version, and others will help you change it if you ask. We've collected help documents for switching PHP versions for a few of them:

Make sure to test your site after switching PHP versions. WordPress and many plugins will also perform better with PHP 7, but some plugins may not be ready for it yet.

Plugin conflicts

Two plugins have been known to cause issues with scans, with certain settings:

  • W3 Total Cache - The "Database cache" can return outdated database records during a scan. All other cache options in W3 Total Cache should be ok if the database cache is disabled. (The database cache can cause issues with some other plugins as well.)
  • Query Monitor - This plugin is helpful for query troubleshooting, but it causes all database queries to be saved, which uses lot of memory during Wordfence scans. We recommend disabling it when you are not actively using it.

Scan process ended after forking

If you get the 'Scan process ended after forking' check and make sure you have not blocked the wp-admin folder with a .htaccess file or limited access to it for the same. Make sure and allow your server's IP address access to this folder.
Shout out to Mike S who helped find this one!
Also check if you have the memcache or object-cache on the site. Memcache may have to be restarted twice in order for the object-cache to get rid of the saved cron key.

LiteSpeed web server settings

If your site is running on a LiteSpeed web server, you will need to adjust settings to prevent the server from aborting long scans:

LiteSpeed aborts Wordfence scans and updates. How do I prevent that?

It was reported by our friend Nick F that adding the following to htaccess helped him.

<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

The Scan page may show "The current scan looks like it has failed"

If the scan has stopped running unexpectedly, the scan page may show this message:

The current scan looks like it has failed. Its last status update was 5 minutes ago.
You may continue to wait in case it resumes or cancel and restart the scan.
Some sites may need adjustments to run scans reliably.

This is often caused by the host stopping processes that run longer than a time limit they have set lower than what they have set in PHP's "max_execution_time", or when the host monitors memory usage of multiple processes rather than only PHP's "memory_limit". Some hosts may have other limits in place. In most cases, the steps above should help, but if not, please see the additional items below and submit a support request if needed.

Advanced users can change the threshold for this message using the WORDFENCE_SCAN_FAILURE_THRESHOLD constant described on the page Wordfence constants for advanced configuration.

Additional scan troubleshooting

If your scan seems to be starting but only runs for a short time, see the additional steps here:

Report any additional problems

Check the Wordfence activity log, which you can get to by clicking “Scan" on the Wordfence menu, then clicking the “Activity Log” tab.

Look for any errors in red that may indicate the reason for the problem. Then report this issue in our support forum with as much detail as you can, including any errors in your site's error log file. Please make sure any errors you include don’t contain sensitive information like usernames or passwords from your site.

You can open a ticket if you are a premium support customer at https://support.wordfence.com, or create a post on our forums if you are a free customer at https://wordpress.org/support/plugin/wordfence Both have paid support staff that can assist you.

Make sure and take the following steps so you can include the information we need to help.

  • Go to your options page
  • Set "Maximum execution time for each scan stage" to 20 on the options page
  • Save the options page
  • Go to the Diagnostics tab on the Tools page on the Wordfence menu
  • Check the box to "Enable debugging mode"
  • Save the diagnostics page.
  • Start a new scan
  • Copy the last 20 lines or so of the activity log and paste them in your post or ticket