When adding an addon domain in cPanel, many users unintentionally enable the “Share document root with primary domain” option. This setting can lead to hidden DNS conflicts and directory overlaps, especially if the domain is removed and re-added later. This guide shows you exactly how to fix it — with guaranteed results.
🔖 What Is the "Share Document Root" Option?
When creating an addon domain, you may see this option:
☑ Share document root (/home/exampleuser/public_html) with "primarydomain.com"
🔎 What it does:
-
Both domains share the same website files
-
No new directory like
/public_html/exampleaddon
is created
❌ Common Scenario (That Causes the Error)
-
User adds
exampleaddon.com
with the "Share document root" option enabled -
Later deletes the domain from cPanel
-
Tries to re-add the domain with its own document root
-
Gets this error:
(XID xxxxx) A DNS entry for the domain “exampleaddon.com” already exists.
Despite the domain being removed, the DNS entry lingers.
🕵️♂️ Root Cause Explained
-
cPanel saves a DNS
A
record for the domain in the primary domain's zone file (/var/named/primarydomain.com.db
) -
This record is not removed when the addon domain is deleted
-
As a result, cPanel throws a conflict error when re-adding
✅ Step-by-Step Fix (With Examples)
⚡ Step 1: Search for Leftover DNS Entries
Run these commands:
grep -Ri "exampleaddon.com" /var/named/
grep -Ri "exampleaddon.com" /etc/named.conf
grep -Ri "exampleaddon.com" /var/cpanel/userdata/
grep -Ri "exampleaddon.com" /etc/userdomains
If found, remove them:
rm -f /var/named/exampleaddon.com.db
sed -i '/exampleaddon.com/d' /etc/userdomains
🔍 Step 2: Edit Primary Domain Zone File
Open:
nano /var/named/primarydomain.com.db
Find and remove this type of entry:
exampleaddon.com 14400 IN A 123.45.67.89
🧹 Step 3: Clean the cPanel User Cache
nano /var/cpanel/users/exampleuser
Remove any line like:
XDNS1=exampleaddon.com
Then:
rm -f /var/cpanel/users.cache/exampleuser
/scripts/updateuserdatacache
/scripts/rebuilddnsconfig
/scripts/rebuildhttpdconf
🚨 Step 4: Restart Required Services
For PowerDNS:
systemctl restart pdns
For BIND:
rndc reload
Also restart:
/scripts/restartsrv_httpd
/scripts/restartsrv_dnsadmin
➕ Step 5: Recreate the Addon Domain (Properly)
Go to:
cPanel → Domains → Create a New Domain
-
Enter
exampleaddon.com
-
❌ Uncheck "Share document root with primary domain"
-
Set folder:
public_html/exampleaddon
💡 Why Avoid "Share Document Root"
-
⚠️ Site conflicts from shared .htaccess files
-
❌ SSL issues, redirect confusion, SEO penalties
-
↩️ Harder to migrate or isolate later
✅ Best Practice: Always assign a unique document root for each domain.
🛡️ Summary Checklist
✅ Step | 🔍 Description |
---|---|
1 | Find & remove stale DNS and config entries |
2 | Manually edit /var/named/*.db to delete ghost A records |
3 | Clear cache: userdata , users.cache , userdomains |
4 | Restart DNS (PowerDNS/BIND) + Apache + DNS Admin |
5 | Recreate domain with separate root folder |
📆 SEO Keywords: cPanel addon domain error, DNS entry exists, shared document root, recreate addon domain, PowerDNS DNS conflict fix, WHM DNS troubleshooting
Would you like this in HTML format or ready-to-upload Markdown for your knowledgebase system?