Error: Cannot add duplicate collection entry…

Refers to:

  • Plesk for Windows

Created:

2016-11-16 12:55:02 UTC

Modified:

2017-01-12 06:05:19 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Error: Cannot add duplicate collection entry…

Symptoms

  1. Adding a new domain in Plesk fails with one of the following errors:

    Error: Unable to update domain data: Execute websrvmng --add-domain "--domain-name=domain.tld" failed with error code 1: Filename: Error: Cannot add duplicate collection entry of type 'site' with unique key attributes 'name, id' respectively set to 'domain.tld, 23'...

    WebServerManager::addSubdomain() failed: websrvmng failed: Site doesn't exist
  2. Repairing website fails with error:

    %plesk_cli%\\repair.exe --reconfigure-web-site -web-site-name domain.tld

    This error message is shown:

        Error: Cannot add duplicate collection entry of type 'site' with unique key attributes 'name, id' respectively set to 'domain.tld, 40'

    In module
    Exception type: System.Runtime.InteropServices.COMException
    at Microsoft.Web.Administration.Interop.IAppHostElementCollection.AddElement(IAppHostElement pElement,Int32 cPosition)
    at Microsoft.Web.Administration.ConfigurationElementCollectionBase`1.Add(T element)
    at Microsoft.Web.Administration.SiteCollection.Add(String name, String bindingProtocol, String bindingInformation, String physicalPath, Byte[] certificateHash)
    at Microsoft.Web.Administration.SiteCollection.Add(String name, String physicalPath, Int32 port)
    at IISWebSites.add(IISWebSites* , unique_ptr<IWebSite\\,std::default_delete<IWebSite> >* , basic_string<wchar_t\\,std::char_traits<wchar_t>\\,std::allocator<wchar_t> >* idnName, list<WebSiteBinding\\,std::allocator<WebSiteBinding> >* bindings, basic_string<wchar_t\\,std::char_traits<wchar_t>\\,std::allocator<wchar_t> >* rootPath, Int64 id)

    (Error code 1)
  3. Site shows error:

    500 Internal server error

Cause

This problem may be caused by a corrupted sites cache. The sites cache contains mapping of sites' names into their internal IDs in the IIS configuration and if it is corrupted, it may cause Plesk to try to add same site twice.

Resolution

Clean the sites cache using the following command:

"%plesk_bin%\\websrvmng" --remove-sites-cache

Reconfigure virtual host if needed:

In Plesk 11 :

For a single virtual host:

"%plesk_bin%\\websrvmng" --reconfigure-vhost --vhost-name=domain.tld

In Plesk 11.5 and higher :

"%plesk_cli%\\repair.exe" --reconfigure-web-site -web-site-name domain.tld

In either case, the sites cache is rebuilt fully.

Have more questions? Submit a request
Please sign in to leave a comment.