Title: Scan terminates with error
Last modified: June 20, 2017

---

# Scan terminates with error

 *  Resolved [Abigailm](https://wordpress.org/support/users/abigailm/)
 * (@abigailm)
 * [8 years, 12 months ago](https://wordpress.org/support/topic/scan-terminates-with-error/)
 * The Wordfence scan is repeatedly failing on one of my sites, with this error:
 * “Scan terminated with error: Unable to query database”
 * Everything else seems to be working ok — any idea what would cause this?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [wfyann](https://wordpress.org/support/users/wfyann/)
 * (@wfyann)
 * [8 years, 12 months ago](https://wordpress.org/support/topic/scan-terminates-with-error/#post-9246481)
 * Hi [@abigailm](https://wordpress.org/support/users/abigailm/),
 * Could you please provide us with additional information by following [these steps](https://docs.wordfence.com/en/My_scans_don&apos;t_finish._What_would_cause_that%3F#Report_any_additional_problems)?
 * Thanks.
 *  Thread Starter [Abigailm](https://wordpress.org/support/users/abigailm/)
 * (@abigailm)
 * [8 years, 12 months ago](https://wordpress.org/support/topic/scan-terminates-with-error/#post-9246626)
 * Sure. Here’s what the last lines of the activity log shows with debug mode on:
 *     ```
       [Jun 20 17:11:16:1498003876.689335:4:info] Scan process ended after forking.
       [Jun 20 17:11:16:1498003876.658167:10:info] SUM_KILLED:Previous scan terminated with an error. See below.
       [Jun 20 17:11:16:1498003876.657860:2:error] Scan terminated with error: Unable to query database
       [Jun 20 17:11:16:1498003876.504768:4:info] Calling Wordfence API v2.23:https://noc1.wordfence.com/v2.23/?v=4.8&s=https%3A%2F%2Fwww.OMITTED.org&k=59311af5a7d2d49979fe7e309df8015cf5ce27e50841e5554fea87e3d1c04d5c2c40aa8d4ce7c5e57f2df7f389106bb0e62286ce0195b70d9f1372920baec36a7b9a122a669e6cf53a62f4eba5aa6617&openssl=268439647&phpv=7.1.6&betaFeed=0&cacheType=disabled&action=record_scan_metrics
       [Jun 20 17:11:16:1498003876.503582:2:info] Done file contents scan
       [Jun 20 17:11:16:1498003876.502088:4:info] Using MySQLi directly.
       [Jun 20 17:11:16:1498003876.501814:4:info] Gathering host keys.
       [Jun 20 17:11:16:1498003876.501506:2:info] Asking Wordfence to check URLs against malware list.
       [Jun 20 17:11:16:1498003876.501077:2:info] Scanned contents of 161 additional files at 9.53 per second
       [Jun 20 17:11:16:1498003876.500575:4:info] No files remaining for malware scan.
       ```
   
 * I am not seeing any errors being logged by wordpress.
 * The site’s apache logs shows some Mod Security errors — they look like this:
 *     ```
       [Tue Jun 20 17:11:37.501714 2017] [:error] ModSecurity: collections_remove_stale: Failed to access DBM file "/tmp/global": Permission denied [hostname "_____"] [uri "/cgi-sys/ea-php71/wp/index.php"] 
       [Tue Jun 20 17:11:37.501770 2017] [:error] ModSecurity: collections_remove_stale: Failed to access DBM file "/tmp/ip": Permission denied [hostname "____"] [uri "/cgi-sys/ea-php71/wp/index.php"] 
       [Tue Jun 20 17:11:37.501812 2017] [:error] ModSecurity: Audit log: Failed to lock global mutex: Permission denied [hostname "_____"] [uri "/cgi-sys/ea-php71/wp/index.php"] 
       [Tue Jun 20 17:11:37.502106 2017] [:error] ModSecurity: Audit log: Failed to unlock global mutex: Permission denied [hostname "_____"] [uri "/cgi-sys/ea-php71/wp/index.php"] 
       ```
   
 *  Thread Starter [Abigailm](https://wordpress.org/support/users/abigailm/)
 * (@abigailm)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/scan-terminates-with-error/#post-9258778)
 * I have now resolved this problem on my own and am going to detail what I did 
   to solve it in case anyone else has similar problems.
 * 1) I did find a different error_log that I had overlooked, in the wp-admin subdirectory(
   which had grown to about 12 megs). This had entries like:
 * `WordPress database error Table 'username_wp123.wp_wfHoover' doesn't exist for
   query SHOW FULL COLUMNS FROM`wp_wfHoover`made by do_action('wp_ajax_nopriv_wordfence_doScan'),
   WP_Hook->do_action, WP_Hook->apply_filters, wordfence::ajax_doScan_callback, 
   wfScan::wfScanMain, wfScanEngine->go, wfScanEngine->doScan, wfScanEngine->scan_fileContents_main,
   wordfenceScanner->scan, wordfenceURLHoover->hoover, wordfenceURLHoover->writeHosts,
   wfDB->queryWrite`
 * I decided to try a clean reinstall.
 * 2) In Wordefence options, I exported my wordfence settings to created a token.
 * 3) In Wordfence options, I checked the box to delete wordfence tables and data
   on deactivation.
 * 4) I deactivated and deleted Wordfence.
 * 5) I reinstalled Wordfence from the wordpress plugin repository.
 * 6) I imported my previously set options using the token I had created.
 * 7) I ran a scan — this time it was successful.
 * So I can only guess that somewhere along the line some entry had been corrupted
   and that Wordfence was not correctly identifying the database, and that with 
   a clean install I forced Wordfence to recreate all tables and solved the problem.
 * From revising the wp-admin/error_log, it looks like this problem might have originated
   in February with an error: “The table ‘wp_wfFileMods’ is full for query insert”—
   which occurred right before the wfHoover doesn’t exist errors started appearing.
   So perhaps the problem originated when Wordfence was unable to write important
   data to to wfFileMods.
 *  [wfyann](https://wordpress.org/support/users/wfyann/)
 * (@wfyann)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/scan-terminates-with-error/#post-9259505)
 * Hi [@abigailm](https://wordpress.org/support/users/abigailm/),
 * Thanks a lot for sharing your findings as well as the solution you’ve applied!
 * This will be helpful to other users.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Scan terminates with error’ is closed to new replies.

 * ![](https://ps.w.org/wordfence/assets/icon.svg?rev=2070865)
 * [Wordfence Security - Firewall, Malware Scan, and Login Security](https://wordpress.org/plugins/wordfence/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordfence/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordfence/)
 * [Active Topics](https://wordpress.org/support/plugin/wordfence/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordfence/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordfence/reviews/)

## Tags

 * [scan fail](https://wordpress.org/support/topic-tag/scan-fail/)

 * 4 replies
 * 2 participants
 * Last reply from: [wfyann](https://wordpress.org/support/users/wfyann/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/scan-terminates-with-error/#post-9259505)
 * Status: resolved