Articles in this section

After removing a WordPress domain in Plesk WP Toolkit starts to show an error: Can not find domain by id X

ext: wptk

Symptoms

  • After removing a domain with a WordPress instance, an error message starts to appear on the Plesk Panel:

    Can not find domain by id 123

  • Email notifications from Plesk may be received by domain owners about application updates:

    Updates were not installed for the following items:
    1. Instance "My Instance Name" (https://example.com): Can not find domain by id 123

  • An attempt to remove a plugin from another Wordpress instance fails with:

    Installation "example": Can not find domain by id 123"

  • The following records can be found in the Plesk log files /var/log/plesk/panel.log on Linux or %plesk_dir%admin\logs\php_error.log on Windows Server:

    Failed to generate screenshot of instance #5: URL of instance #5 is empty
    ERR [extension/wp-toolkit] Can not find domain by id 123

  • Unable to remove Wordpress instance via Applications. The following message is returned on a blank page:

    {"status":"success"}

  • The Wordpress instance files were manually removed from /var/www/vhosts/example.com/httpdocs.

Cause

Orphaned data in WordPress SQLite database for the removed domain

Resolution

Apply the corresponding steps:

For Plesk on Linux Server
  1. Connect to the Plesk server via SSH.
  2. Create a backup dump of the 'psa' database.
  3. Remove any possible tasks leftover from the Plesk database:

    # plesk db "truncate longtasks"
    # plesk db "truncate longtaskparams"

  4. Create a backup of the WP Toolkit database:

    # cp -p /usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3{,.backup}

  5. Access the WP Toolkit database in SQLite:

    # sqlite3 /usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3

  6. Enable headers:

    # sqlite> .headers on

  7. Get a WordPress instance ID using the domain ID from the error message. In this example, domainId is 123:

    # sqlite> select Id from Instances where domainId=123;
    id
    567

  8. Remove all corresponding information:

    sqlite> DELETE FROM InstanceProperties WHERE instanceId=567;
    sqlite> DELETE FROM InstancesDomains WHERE instanceId=567;
    sqlite> DELETE FROM Instances where id=567;

    Note: If more than one instance id was listed on the previous step output, execute the above InstanceProperties, InstanceDomains and Insntances deletions for each ID number accordingly.

  9. Exit SQLite:

    # sqlite> .quit

  10. (Optional) If there are errors for multiple domain IDs, you can obtain all affected domain IDs with this command: 

    # plesk ext wp-toolkit --list

    Copy and paste each ID from the error output in /root/domain_ids.txt. Each line should contain only one domain ID. After all domain IDs have been saved to the file, execute the following one-liner to clean up the orphaned records for all affected domains:

    # DB_PATH="/usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3"; ID_FILE="/root/domain_ids.txt"; while read -r DOMAIN_ID; do echo "Processing $DOMAIN_ID"; while read -r INSTANCE_ID; do sqlite3 "$DB_PATH" "DELETE FROM InstanceProperties WHERE instanceId=$INSTANCE_ID;"; sqlite3 "$DB_PATH" "DELETE FROM InstancesDomains WHERE instanceId=$INSTANCE_ID;"; sqlite3 "$DB_PATH" "DELETE FROM Instances WHERE id=$INSTANCE_ID;"; echo "Deleted $INSTANCE_ID"; done < <(sqlite3 "$DB_PATH" "SELECT Id FROM Instances WHERE domainId=$DOMAIN_ID;"); done < "$ID_FILE"

     

For Plesk on Windows Server
  1. Connect to the Plesk server via RDP.
  2. Download the command tool for managing SQLite databases and extract sqlite3.exe into %plesk_dir%var\modules\wp-toolkit.
  3. Create a backup of the 'psa' database.
  4. Open a command prompt (CMD) as Administrator and remove possible tasks leftovers from the Plesk database:

    C:\> plesk db "truncate longtasks"
    C:\> plesk db "truncate longtaskparams"

  5. Create a backup copy of the WP Toolkit database:

    C:\> copy "%plesk_dir%var\modules\wp-toolkit\wp-toolkit.sqlite3" "%plesk_dir%var\modules\wp-toolkit\wp-toolkit.sqlite3.bak"

  6. Open the downloaded tool and access the WP Toolkit database:

    C:\> "%plesk_dir%var\modules\wp-toolkit\sqlite3.exe" "%plesk_dir%var\modules\wp-toolkit\wp-toolkit.sqlite3"

  7. Enable headers:

    sqlite> .headers on

  8. Get a WordPress instance ID using the domain ID from the error message. In this example, domainId is 123:

    sqlite> select instanceId from Instances where domainId=123;
    instanceId
    567

  9. Remove all corresponding information leftovers:

    sqlite> DELETE FROM InstanceProperties WHERE instanceId=567;
    sqlite> DELETE FROM InstancesDomains WHERE instanceId=567;
    sqlite> DELETE FROM Instances where id=567;

    Note: If more than one instance id was listed on the previous step output, execute the above InstanceProperties, InstanceDomains and Insntances deletions for each ID number accordingly.

  10. Exit from sqlite3.exe then close the CMD console:

    sqlite> .quit

Click on a section to expand

Was this article helpful?

Comments

1 comment
Date Votes
  • What is the difference between the SQLite tables Instances and InstancesDomains?

    In my case, I get error messages such as:

    Failed to execute maintenance: Can not find domain by id 11

    or

    Failed to detect owner of WordPress instance WordPress installation #15 ('https://old-domain.com'): Can not find domain by id 61

    When looking up entries in table InstanceDomains, I do not find id 11 or 61. However, they DO exist in table Instances. So I assume you should adjust step 8 as it also allows to find the instanceID from the table instances (named id in that table).

    0

Please sign in to leave a comment.