This error occurs while creating SharePoint site collection.

Error Occurs while executing below ps script:

$web = Get-SPWebApplication http://spapp:1400/
New-SPSite http://spapp:1400/ -OwnerAlias "ad\farmUser" -HostHeaderWebApplication $web -Name "Demo Team Site<Site name>" -Template STS#0

Exact error:

New-SPSite : The URL "http://Intranet" is in use as an alternate access URL or as the URL of a host header site.  
Please choose a different URL and try again.
At line:3 char:1
   + New-SPSite http://Intranet  -OwnerAlias "mars\aaronp" `
   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletNewSite:SPCmdletNewSite) [New-SPSite], ArgumentException
   + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSite

Cause of Error:

SharePoint prevents the creation of a host-named site collection with the same URL as a Web application.

If you want to create a Root Site Collection a the top level of your Web application you should not use the parameter: -HostHeaderWebApplication in the New-SPSite command.

Therefore, the root site collection is created as a path-based site collection: “/”


Remove: -HostHeaderWebApplication $web

New Powershell scripts:

$web = Get-SPWebApplication http://spapp:1400/
New-SPSite http://spapp:1400/ -OwnerAlias "ad\farmUser" -Name "Demo Team Site" -Template STS#0

Kind Regards

By Rijwan Ansari

Research and Technology Lead | Software Architect | Full Stack .NET Expert | Tech Blogger | Community Speaker | Trainer | YouTuber. Follow me @ Md Rijwan Ansari is a high performing and technology consultant with 10 plus years of Software Development and Business Applications implementation using .NET Technologies, SharePoint, Power Platform, Data, AI, Azure and cognitive services. He is also a Microsoft Certified Trainer, C# Corner MVP, Microsoft Certified Data Analyst Associate, Microsoft Certified Azure Data Scientist Associate, CSM, CSPO, MCTS, MCP, with 15+ Microsoft Certifications. He is a research and technology lead in Tech One Global as well as leading Facebook community Cloud Experts Group and SharePoint User Group Nepal. He is a active contributor and speaker in community, C# Corner MVP and his rank at 20 among 3+ millions members. Additionally, he is knee to learn new technologies, write articles, love to contribute to the open-source community. Visit his blog RIJSAT.COM for extensive articles, courses, news, videos and issues resolution specially for developer and data engineer.

Leave a Reply

Your email address will not be published. Required fields are marked *