cPanel/WHM

[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

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

 

 

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

 

 

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.

Sufiyan Shaikh

Recent Posts

CyberPanel Server Error (500)

Server Error (500) when trying to access the Cyberpanel If you are getting this error while accessing the cyberpanel, there…

1 year ago

How to connect and use github with DirectAdmin git feature

How to connect git with DirectAdmin Login into SSH and run the following command to create a new key pair…

1 year ago

How to host next js app on cpanel

How to host next js app in cpanel Login > Setup Node.js App > Create Application Enter the values shown…

1 year ago

WHMCS Development environment set

Update via PHPMYADMIN: Disable Captcha : UPDATE tblconfiguration SET value = '' WHERE setting = 'CaptchaSetting'; Update WHMCS link: UPDATE…

1 year ago

Lagom WHMCS notification hide pages list

3dsecure Access Denied Affiliates Affiliates Signup Announcements Banned Configure Products Downloads Downloads Denied Error Login Logout Password Reset Ticket Feedback…

1 year ago

Export/Import database via command line(ssh)

Export Database via SSH mysqldump --routines -u databaseusername -p databasename > database.sql   Import Database via SSH mysql -u databaseusername…

1 year ago