Symptoms
-
When creating a new domain/subdomain/alias, migrating an existing domain/subdomain or activating the mail service for a domain, the operation fails with one of the following errors:
DNS records for domain with such name already exist
The subdomain with such name already exists
This DNS record already exists.
Unable to create the subdomain test.example.com. because a DNS record pointing to the host test.example.com. already exists.
Unable to create the domain example.com because a DNS record pointing to the host example.com already exists.
Unable to set up the domain alias example.net because a DNS record pointing to the host example.net already exists.
DNS records for a domain with such a name already exist.
-
On attempt to apply the changes to DNS template at Tools & Settings > DNS Template > Apply DNS Template Changes, the operation fails with the following error message:
There were issues syncing DNS zones with the DNS zone template.
Unable to resolve dns zone
Cause
Orphaned DNS records exist in the Plesk database.
Resolution
For Plesk on Linux
-
Connect to the Plesk server via SSH.
-
Create a database dump of the Plesk database (for more information, see this KB article):
# plesk db dump psa > /root/psa_backup.sql
-
Access the Plesk database:
# plesk db
-
Find
dns_zone_id
of the domain, which cannot be created, using the following command. Replace example.com with an actual domain name:mysql> select dns_zone_id,host from dns_recs where host like "%example.com%";
+-------------+---------------------+
| dns_zone_id | host |
+-------------+---------------------+
| 3 | www.example.com. |
| 3 | example.com. |
| 3 | ns2.example.com. |
| 3 | ns1.example.com. |
| 3 | example.com. |
| 3 | ftp.example.com. |
| 3 | example.com. |
| 3 | example.com. |
| 3 | _dmarc.example.com. |
| 3 | example.com. |
| 3 | mail.example.com. |
| 3 | ipv4.example.com. |
+-------------+---------------------+ -
Using
dns_zone_id
from the output above, make sure that the domain name is the same:Note: In some cases the output may be empty.
mysql> select id,name from dns_zone where id=3;
+----+-------------+
| id | name |
+----+-------------+
| 3 | example.com |
+----+-------------+ -
Delete records from corresponding tables using the ID from the steps above. In case all zones for all domains need to be removed the
where id=x
can be omitted:mysql> delete from dns_zone where id=3;
mysql> delete from dns_recs where dns_zone_id=3;
mysql> delete from dns_refs where zoneId=3; -
Exit MySQL:
mysql> exit
-
Create the domain/subdomain/alias in Plesk / Rerun the migration/restore.
For Plesk on Windows
-
Connect to the Plesk server via RDP.
-
Create a database dump of the Plesk database (for more information, see this KB article):
plesk db dump psa > C:psa_backup.sql
-
Access the Plesk database:
plesk db
-
Run these commands to remove orphaned records:
delete from dns_recs where dns_zone_id in (select id from dns_zone where id not in (select dns_zone_id from domains) and id not in (select dns…