If you are trying to add-on a domain in cPanel and get “Domain already exists” messages, you will have to manually remove the DNS entries before you can add the domain.
If you are unsure who the user is – run this via SSH to get the owner of the domain:
First we need to check if the domain is owned by any particular user.
server# /scripts/whoowns domain.com
or
server# grep domain.com /etc/userdomains
domain.com:username
Now we need to check if the zone file for the domain exists.
server # ls -ld /var/named/domain.com.com.db
-rw------- 1 named named 1055 Mar 4 02:57 /var/named/domain.com.com.db
There exists a zone file for the domain and can remove the zone by executing the below command:
server #/scripts/killdns domain.com
These are the locations to search for any reference to domain.com
/var/cpanel/userdata/<username>/main
/etc/named.conf
/usr/local/apache/conf/httpd.conf
/var/named/domain.com.db
/etc/userdomains
/etc/localdomains
/var/cpanel/users/<username>
Edit any files that are found and remove the entire line that contains the domain name. Once you’ve done this, there shouldn’t be any entry for domain.com in the cPanel configuration file.
Rebuild the User domain database:
server #/scripts/updateuserdomains
Rebuild the Apache configuration
server #/scripts/rebuildhttpdconf
If the server is running on apache
server # service httpd restart
server # service cpanel restart
You should now be able to add the domain in the ‘add-on domains’ section in cPanel.
If you are unsure who the user is – run this via SSH to get the owner of the domain:
First we need to check if the domain is owned by any particular user.
server# /scripts/whoowns domain.com
or
server# grep domain.com /etc/userdomains
domain.com:username
Now we need to check if the zone file for the domain exists.
server # ls -ld /var/named/domain.com.com.db
-rw------- 1 named named 1055 Mar 4 02:57 /var/named/domain.com.com.db
There exists a zone file for the domain and can remove the zone by executing the below command:
server #/scripts/killdns domain.com
These are the locations to search for any reference to domain.com
/var/cpanel/userdata/<username>/main
/etc/named.conf
/usr/local/apache/conf/httpd.conf
/var/named/domain.com.db
/etc/userdomains
/etc/localdomains
/var/cpanel/users/<username>
Edit any files that are found and remove the entire line that contains the domain name. Once you’ve done this, there shouldn’t be any entry for domain.com in the cPanel configuration file.
Rebuild the User domain database:
server #/scripts/updateuserdomains
Rebuild the Apache configuration
server #/scripts/rebuildhttpdconf
If the server is running on apache
server # service httpd restart
server # service cpanel restart
You should now be able to add the domain in the ‘add-on domains’ section in cPanel.