Applicable to:
- Plesk for Linux
- Plesk for Windows
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:
PLESK_ERROR: DNS records for domain with such name already exist
PLESK_ERROR: The subdomain with such name already exists
PLESK_ERROR: This DNS record already exists.
PLESK_ERROR: Unable to create the subdomain test.example.com. because a DNS record pointing to the host test.example.com. already exists.
PLESK_ERROR: Unable to set up the domain alias example.net because a DNS record pointing to the host example.net already exists.
PLESK_ERROR: 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:
PLESK_WARN: 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
-
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_LIN: 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_LIN: 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_LIN: 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_LIN: mysql> exit
-
Create the domain/subdomain/alias in Plesk / Rerun the migration.
-
Connect to the Plesk server via RDP.
-
Create a database dump of the Plesk database (for more information, see this KB article):
C:\> plesk db dump psa > C:\psa_backup.sql
-
Access the Plesk database:
C:\> plesk db
-
Run these commands to remove orphaned records:
MYSQL_WIN: 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_zone_id from domain_aliases));
MYSQL_WIN: delete from dns_zone where id not in (select dns_zone_id from domains) and id not in (select dns_zone_id from domain_aliases);
-
Exit MySQL:
MYSQL_WIN: mysql> exit
-
Create the domain/subdomain/alias in Plesk / Rerun the migration.
Comments
6 comments
How to solve probleme if no ssh access?
@cit dev
SSH is mandatory in this case because Plesk database cannot be accessed via GUI. Please contact your server provider in order to solve it.
Ok thanks!
Thanks !
Thanks, we had a migration fail and could not be resolved until I ran the sql commands to clear the already existing records.
I had a similar problem with the relation of a virtual machine to the domain (https://fahadkhan.pk). I ended up on the computer I wanted to enter absolutely static. I set up and then restarted the static IP information and DNS information. I entered this domain and was successful after restarting.
Please sign in to leave a comment.