jameshurrell

Member
Feb 17, 2011
11
1
53
A client had two subdomains configured in cPanel (UK and USA). They redirected to public_html/folder/uk and public_html/folder/usa.

This worked fine, however, the client wanted to clean it up and place the UK and USA folders directly in public_html. Rather than edit the subdomains, he deleted them. This seemed to work OK (they are not listed in cPanel nor in WHM), but he cannot now re-add the subdomains. Instead there is an error:

Error from domain wrapper: Domain already exists, it was not added.: uk.domain.co.uk
Googling this error brings up lots of people with similar issues. I checked the httpd.conf file and the subdomains are still listed there too under virtual hosts - I guess that cPanel has left a trail of data somewhere which is getting pulled into various config files.

Does anyone have any idea what I need to "clean" to get rid of these domains so that they can be recreated again?

Many thanks.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

You would want to check the following locations:

/var/cpanel/userdata/username/main
/var/cpanel/userdata/username/sub.maindomain.com
/var/cpanel/users/username
/var/named/maindomain.com.db

Any of the above if it has traces of the subdomain will cause the subdomain to continue to be considered existing on the system. Simply make a copy of the file you are editing and then remove the subdomain. For the /var/cpanel/userdata/username/sub.maindomain.com file, simply move the file out of the way. For the /var/named/maindomain.com.db file, you could edit it in WHM > Edit a DNS zone if the subdomain is still there rather than edit that file directly.

If you did find the subdomain listed in any of the /var/cpanel/userdata/username files, you would need to run the following commands after removing it in the main file there and moving the sub.maindomain.com file there:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110217
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
You would also likely want to run this script after that or possibly after editing /var/cpanel/users/username file:

Code:
/scripts/updateuserdomains
If you directly edited the /var/named/maindomain.com.db file rather than editing it in WHM > Edit a DNS Zone, you'd need to run this command:

Code:
rndc reload
In all of the above, username is the cPanel username, maindomain.com is the main domain name, and sub.maindomain.com is the subdomain name.

Thanks.
 

jameshurrell

Member
Feb 17, 2011
11
1
53
Thank you Tristan.

The only place where any of the subdomains were mentioned was in:

/var/cpanel/users/username

I copied the file and removed two lines:

XDNS1=uk.hurrell-it.co.uk
XDNS2=usa.hurrell-it.co.uk

I then ran:

/scripts/updateuserdomains

I also ran:

cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak18022011
/scripts/rebuildhttpdconf

And then restarted Apache. This removed the Vitual Hosts for the subdomains from httpd.conf.

However, I still cannot re-add the subdomains but I have a different error:

Error from domain wrapper: We were unable to locate your current domain name, hurrell-it.co.uk in the webserver configuration! The subdomain cannot be added because information about your domain could not be obtained from the webserver configuration file.
and there are other problems with the account within cPanel now:

1) in the "Error Log" there is simply "nolog.html" listed.
2) The "Advanced DNS ZOne Editor" lists:

Error
You do not have permission to read the zone for : hurrell-it.co.uk
click to close
No Zone Records Found

Which is very odd...

I'm tempted to delete the account through WHM and recreate it as there seems to be quite a bit of mess going on...

Thanks for any advice.
 

jameshurrell

Member
Feb 17, 2011
11
1
53
SOmething very odd occurred in this account, so i deleted it and recreated it. Hey presto, all back working. I will remember to avoid creating subdomains through cPanel in the future.
 

Infopro

Well-Known Member
May 20, 2003
17,113
507
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Creating subdomains via cPanel should not be a problem. The issue here is not uncommon though, IMHO.
The user creates something one way, and then decides to kill it by simply deleting what he sees in front of him without realizing that the proper way is to remove what ever it is the same way they installed it originally.

That's not a system issue, thats an end user mistake.

I see this often with Fantastico users.
 

crazyaboutlinux

Well-Known Member
Nov 3, 2007
939
0
66
Deleting an account & recreating the same is probably not a good idea, you had to contact your DC they would able to manually remove it from httpd.conf file.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
somewhere over the rainbow
cPanel Access Level
Root Administrator
Deleting an account & recreating the same is probably not a good idea, you had to contact your DC they would able to manually remove it from httpd.conf file.
Please note that you cannot manually remove a domain in httpd.conf file directly. It must be removed in the /var/cpanel/userdata/username files instead with the steps I noted earlier. If you manually remove a domain in httpd.conf file, it will end up back in that file when /scripts/rebuildhttpdconf is called, which happens on EasyApache update.
 

jameshurrell

Member
Feb 17, 2011
11
1
53
Creating subdomains via cPanel should not be a problem. The issue here is not uncommon though, IMHO.
The user creates something one way, and then decides to kill it by simply deleting what he sees in front of him without realizing that the proper way is to remove what ever it is the same way they installed it originally.

That's not a system issue, thats an end user mistake.

I see this often with Fantastico users.
Creating domains via cPanel works fine, however, deleting them via cPanel does not. Yes, they were removed from the "subdomains" list, but try recreating them again and you won't be able to. cPanel didn't remove the references it should have done when the "Delete subdomain" button was pressed.

In this instance, this is not an end-user error.
 
  • Like
Reactions: David Colter