Running IIS Express with admin privileges

38,748

Solution 1

I've worked it out.

I switched Visual Studio to running with Administrative Privileges and also found the .exe for IIS Express and set that to always run with administrative privileges. I'm not 100% sure the second was needed but did them both anyway.

I hope this helps some one else who's had this same issue.

EDIT

(19/08/2013)

This only seemed to work in Windows 7, On Windows 8 I eventually just gave up and now use the full blow IIS for all my dev work.

EDIT

(07/06/2018)

@Tarostar (Comment below), got this working on Windows 10 VS2017 and a number of others have got it to work on Windows 8 prior to that using the same method. So possible I was doing something wrong on my Windows 8 box.

Solution 2

For Visual Studio 2015 and 2012 this solution will work.

  1. Go to Solution Explorer in Visual Studio, right click the web project and select "Unload Project"
  2. Next on the same project, right click and select ‘Edit Project File‘
  3. Find the
    <DevelopmentServerPort>0</DevelopmentServerPort><IISUrl>http://localhost:56058/</IISUrl>
    xml tags and and remove them.
  4. Reload the project and run.

Images to follow:

enter image description here

Solution 3

In my case, the site was working without admin privileges and at some point stopped and worked only with admin.

Port number was higher than 1024 which does not require admin privileges, but Visual Studio 2015 refused to run a site without admin permissions.

I figured out that, it was because of it was added in

netsh http show urlacl

which showed me

Reserved URL            : http://*:15888/
        User: \Everyone
            Listen: Yes
            Delegate: No
            SDDL: D:(A;;GX;;;WD)

So for my case, I have removed it from this list and it worked again. Here is the command for removing:

netsh http delete urlacl http://*:15888/

Solution 4

Although a bit late, and not an answer to the asked question 'how to run with administrative privileges', this might be a solution to the stated problem/error:

Cannot start the website because administrative privileges are required to bind to the hostname or port

As mentioned in running-iis-express-from-the-command-line, the port number used may require these administrative privileges:

you must have Administrator user rights if you want to run IIS Express on ports numbered 1024 or less.

So if you could run on a port number higher than 1024, you might not need administrative privileges at all.

Solution 5

This is not a way to give admin privileges to ISS but a solution to error in the post. I started seeing this error one morning, and solved this by closing Mobile hotspot of my computer. Apparently something about sharing your internet with other devices might result in "Can not start the website because administrative privileges are required to bind to the hostname or port" error.

Share:
38,748
Morvael
Author by

Morvael

Day job: Software developer at Canal &amp; River Trust, full stack development of the internal reporting systems, and graphic data displays via the web. When I'm not on the job: Generally chilling out and starting projects that I never seem to have time to finish. Taking photographs and playing with image editing.

Updated on January 31, 2021

Comments

  • Morvael
    Morvael about 3 years

    This has been asked before but was closed as "Not a real question"

    https://stackoverflow.com/questions/7450813/how-to-run-a-site-with-administrative-privileges-in-iis-express-7-5

    However I think it is a genuine question as I also need to do this, there are MS documents explaining how to "Run IIS Express without Administrative Privileges" but as this is how it runs by default the need for this article quite frankly baffles me. However I have no idea on how to run it with Admin privileges.

    When I try to start my VS2012 website I get the following error message from IIS express: "Cannot start the website because administrative privileges are required to bind to the hostname or port", and links are provided to the MS documents about running it without admin privileges.

    What I'm ultimately trying to do is run my dev sites locally as http ://vs2012:nnnnn, this is so I can attach fiddler debugger (due to the bypass of proxies in IE when localhost is used)

    This used to work fine, this morning I did a reinstall of windows and have now hit a brick wall!

    Does anyone know how to give IIS express admin privileges as indicated in the error message?

  • moribvndvs
    moribvndvs about 11 years
    Just to clarify, I only needed to ensure VS was running as Administrator and it worked.
  • Yahoo Serious
    Yahoo Serious about 11 years
    Maybe this can save some time, my IIS Express is located here: C:\Program Files (x86)\IIS Express\IISExpress.exe.
  • Aurril
    Aurril almost 11 years
    Unfortunatly if you don't want to bind your website to localhost you always need Administrator user rights, regardless of the chosen port number.
  • Yahoo Serious
    Yahoo Serious almost 11 years
    @Aurril: Thanks for the info. Is this valid for all 'external' bindings, even if you use local addresses, like the local IP-range? Do you have a reference/link, I can add to the answer?
  • Aurril
    Aurril almost 11 years
    As far as I recall, all adresses outside the 127/8 block will require admin privileges. See iis.net/learn/extensions/using-iis-express/… section "RUNNING SITES LOCALLY".
  • Nick Coad
    Nick Coad over 9 years
    Confirming that this works in Windows 8 for Visual Studio 2013 - I ran VS as Administrator and IIS Express was automatically elevated as well.
  • Raphael Ahrens
    Raphael Ahrens over 9 years
    This worked for me on Windows 8.1, but I needed to at a Firewall rule that allowed connection from my LAN. Only then I could connect to the server.
  • Oswin
    Oswin over 7 years
  • Tarostar
    Tarostar almost 6 years
    Running Visual Studio as admin (right click menu) solves the problem as described before the edit as per June 2018 with Win10 and VS2017, all patched with the latest. I got "iis express cannot start the website because administrative privileges are required to bind to the hostname or port" when I needed to map localhost to a domain name in the hosts file in order to debug a cookie issue. As this is a .net core 2.0 project I specify the hostname in the applicationUrl in launchSettings.json. Thanks to Morvael for figuring it out (but you should probably remove the edit).
  • Tony Rush
    Tony Rush over 5 years
    Works in VS2017 as well
  • Gautam Jain
    Gautam Jain over 4 years
    Wow. Thanks a lot. Easy solution.
  • saadasharif
    saadasharif about 4 years
    Worked for me. Thanks much
  • Gideon Mulder
    Gideon Mulder over 3 years
    Works in VS2019 as well
  • tallman
    tallman over 2 years
    Works in VS2022 as well for me.