52

I'm using IIS Express to create a virtual directory at http://localhost:5000/ and received this error:

Unable to create the virtual directory. The URL http://localhost:5000/ is already mapped to a different folder...

This is because I've used the port 5000 for an old project before and it's no longer needed.

My question is, how can I remove the old mapping using IIS Express so I can create the virtual directory at the same port again?

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Leon
  • 1,011
  • 1
  • 11
  • 28

4 Answers4

86

You should be able to accomplish this in one of two ways.

  • You can remove the old project, or change its port using WebMatrix, which has an administration interface for IIS Express.
  • You can also do it by hand, by modifying the applicationhost.config file directly. The file is located in the %userprofile%\documents\IISexpress\config folder. You can find the project configuration under the <system.applicationHost>/<sites> element.

UPDATE: WebMatrix has been discontinued and support has officially ended.

Garett
  • 16,632
  • 5
  • 55
  • 63
  • 3
    I also had to delete the site folder underneath %userprofile%\documents\my web sites\ before I was able to reuse the port number. – Tedford Nov 11 '11 at 23:14
  • 1
    Also, if running as administrator, be sure to check Users\\[admin acct name]\My Documents\IISExpress\config\applicationhost.config – anon Mar 29 '14 at 14:12
  • **1-** I've created a virtual directory (VD) using IIS. **2-** Added the VD name to the host file in `drivers -> etc`. **3-** Changed the settings in `` portion of `applicationHost.config` file. I'm still unable to run my application. On going to `Project -> Properties -> Web` and replacing the project url with my VD following alert is generated: `Local IIS Express URL:*something* specified for Web Project *someProject* has not been configured. To keep these settings u need to configure the VD. Would u like to create the VD now?`. – phougatv Mar 14 '16 at 14:26
  • How should I be able to set my VD path as the default project URL so that on hitting `F5` the browser should show: `myPath.com`? – phougatv Mar 14 '16 at 14:28
4

No software installation required. Simply follow the steps:

Right-click the project node in the solution explorer and select the option to edit the project (.csproj) file. Near the bottom of the file, find the following:

<iisurl></iisurl>

Edit this entry to add your virtual directory:

<iisurl>http://localhost:5000/</iisurl>

  • This might have worked for you but it's also possible you will break the proj file such that the project won't load into Visual Studio [2012 in my case], especially if you modify an existing entry. – Bernard Dy Sep 10 '15 at 14:00
0

I was getting this because I had a site on the IIS Server (not express) with the same bindings (domain name and port) as IIS Express was trying to use.

I thought that since the site was not started it would ignore it, but I was wrong. Once I change it in IIS, then the IIS Express one worked and the error went away.

johntrepreneur
  • 4,514
  • 6
  • 39
  • 52
0

Seems you need to run Visual Studio with administrative rights if you want to create Virtual directory on ports below 1024.