[Solved] The domain already exists in the Apache configuration

You might be getting error “The domain “hostathash.com” already exists in the Apache configuration” even when there is no user account or addon domain record found in cPanel.
So why you are getting this error?
Well. The simple answer is that there are leftovers of older DNS records which are still present in the server is now conflicting.
We must delete the old records in order to fix the error and add our domain.

We’ll be following a bunch of steps in order to find where exactly the record are present and are conflicting.

Condition 1 Solution

Login into your server as root and execute the following command

dig YOURSERVERIP hostathash.com

Replace YOURSERVERIP with your Server IP and hostathash.com with your domain name you are getting error with
The results will be shown similar to this

dig-response

We  can see that there is an “A record” present in server and that’s the reason we are getting the error while adding the Addon domain.

We’ll now check on which user account this DNS is present by the below command
(Replace hostathash.com with your Domain name)

/scripts/whoowns hostathash.com

whoowns

 

 

As you can see, the username owning is the cPanel user “hostathash”.
You can delete it by deleteting the cPanel account of the user.

If you get the same error while adding the Addon domain, follow the below method.

 

Now we’ll force DNS entry delete by the below command
(Replace hostathash.com with your Domain name)

/scripts/killdns hostathash.com

The results will be shown similar to this
killdns

 

 

Condition 2 Solution

MAKE SURE TO CREATE A BACKUP BEFORE EDITING/DELETING ANY FILE. 

1) We’ll now check if there is any cPanel data that is causing issues by using the below command
(Replace hostathash.com with your Domain name)

grep domain.com /var/cpanel/users/*

As we get the entries and the file location, we’ll edit/delete the file so that the records are removed.

2) Now lets check if we have any more data in cPanel
(Replace hostathash.com with your Domain name)

grep -R hostathash.com /var/cpanel/userdata/*

As we can see there are files leftover, we’ll delete the lines that contains the domain name we are trying to add. You may also need to delete files in /var/cpanel/userdata/USERNAME/ directory.

3) We need to rebuild the user domains database so that changes are applied by the below command

/scripts/updateuserdomains

4) We also need to rebuild Apache so that apache settings are also updated.

/scripts/rebuildhttpdconf ; service httpd restart

After following all the steps, you should be able to add your Addon domain without any errors.
If you are facing any issues, let us know in the comments.

Leave a Comment