When adding a new DNS records in cPanel > Zone Editor there is an error:
![The DNS zone file is invalid. Line X: ignoring out-of-zone data image 21 - The DNS zone file is invalid. Line X: ignoring out-of-zone data](https://i0.wp.com/pcx3.com/wp-content/uploads/2022/04/image-21.png?resize=500%2C74&ssl=1)
Error: The DNS zone file is invalid. (Line 20: ignoring out-of-zone data (ns1.solutions.rs); Line 21: ignoring out-of-zone data (ns2.solutions.rs))
How to fix error
Check if the DNS zone is valid by running:
named-checkzone domain.com /var/named/domain.com.db
Output will show you which lines are causing the problem:
![The DNS zone file is invalid. Line X: ignoring out-of-zone data image 19 - The DNS zone file is invalid. Line X: ignoring out-of-zone data](https://i0.wp.com/pcx3.com/wp-content/uploads/2022/04/image-19.png?resize=640%2C88&ssl=1)
so now just edit the file and comment the lines (in my case 20 and 21) by adding a semi-colon at the beginning ( ; )
nano /var/named/domain.com.db
turn on line number display in nano with alt shift C
then navigate to the lines (in my case 20 and 21) and comment them:
![The DNS zone file is invalid. Line X: ignoring out-of-zone data image 20 - The DNS zone file is invalid. Line X: ignoring out-of-zone data](https://i0.wp.com/pcx3.com/wp-content/uploads/2022/04/image-20.png?resize=736%2C346&ssl=1)
exit with ctrl x then save with y
Now go back to cpanel and add/edit records that you wish.
Why did this happen?
The DNS zone can be corrupted for a variety of reasons; in my instance, the default zone templates were causing issues because my nameservers were on the same server and the template required that every new domain have the following records:
![The DNS zone file is invalid. Line X: ignoring out-of-zone data image 22 - The DNS zone file is invalid. Line X: ignoring out-of-zone data](https://i0.wp.com/pcx3.com/wp-content/uploads/2022/04/image-22.png?resize=736%2C603&ssl=1)
So I won’t have this problem with new domains if I just remove these records from the template.