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.logon Linux or%plesk_dir%admin\logs\php_error.logon 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:
- Connect to the Plesk server via SSH.
- Create a backup dump of the 'psa' database.
-
Remove any possible tasks leftover from the Plesk database:
# plesk db "truncate longtasks"
# plesk db "truncate longtaskparams" -
Create a backup of the WP Toolkit database:
# cp -p /usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3{,.backup}
-
Access the WP Toolkit database in SQLite:
# sqlite3 /usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3
-
Enable headers:
# sqlite> .headers on
-
Get a WordPress instance ID using the domain ID from the error message. In this example,
domainIdis 123:# sqlite> select Id from Instances where domainId=123;
id
567 -
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.
-
Exit SQLite:
# sqlite> .quit
-
(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"
- Connect to the Plesk server via RDP.
-
Download the command tool for managing SQLite databases and extract
sqlite3.exeinto%plesk_dir%var\modules\wp-toolkit. - Create a backup of the 'psa' database.
-
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" -
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"
-
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"
-
Enable headers:
sqlite> .headers on
-
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 -
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.
-
Exit from
sqlite3.exethen close the CMD console:sqlite> .quit
Click on a section to expand
Comments
What is the difference between the SQLite tables Instances and InstancesDomains?
In my case, I get error messages such as:
or
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).
Please sign in to leave a comment.