ChatGPT解决这个技术问题 Extra ChatGPT

Unable to launch the IIS Express Web server, Failed to register URL, Access is denied

Some web projects are causing me problems while others work fine. I decided to focus on one of the problematic ones. I'm using Visual Studio 2013 on Windows 7. I think I'm running it as administrator, the window title says PROJECT NAME - Microsoft Visual Studio (Administrator).

When I try to run the project I get a popup saying:

Unable to launch the IIS Express Web server. Failed to register URL "http://localhost:62940/" for site "SITE NAME" application "/". Error description: Access is denied. (0x80070005).

This does not seem entirely uncommon but I have tried many of the suggestions without luck:

Deleted %userprofile%\Documents\IISExpress\, tried to run. netsh http add urlacl url=http://localhost:62940/ user=everyone, rebooted and tried to run. (Actually user=Alla since Swedish Windows). netsh http delete urlacl url=http://localhost:62940/, rebooted and changed from

I'm at my wit's end, what am I doing wrong?

If I change the port of the project (e.g. to 55555) it starts... This is not a desirable solution since these projects are worked on by several people. Maybe the port is blocked by something else? If so, is there an easy way to check by what?

Port 62940 seems to be free. Running netstat does not show any application listening to it. Something else must be wrong.

I tried starting the project today after not touching it for a few months. It worked but I don't know why.

Run netstat -aon | findstr to see if another application also monitors port 62940. If so, you cannot monitor that port but have to switch to another port. Don't change applicationHost.config or netsh http when they are obviously not the cause.
I ran netstat as suggested. No application seems to be monitoring port 62940. Something else must be wrong.
Rebooting worked for me.
Restarting VS solved the issue for me.

F
Francisco

I solved the error by changing the port for the project.

I did the following steps:

1 - Right click on the project. 2 - Go to properties. 3 - Go to Server tab. 4 - On tab section, change the project URL for other port, like 8080 or 3000.

Good luck!


just kill the Microsoft.VisualStudio.Web.Host.exe*32 process as Avrohom Yisroel says.
Also worked for me on ASP.NET Core 1.0 RC1, although it is now in Debug tab and I had to toggle SSL Enable off and on again to generate a new port then copy that to Launch URL box. stackoverflow.com/a/35706891/134761
Why upvote this? This is not a solution, is a workaround
Like @rotgers said, I had to kill a process. But mine was ServiceHub.Host.CLR. I had 5 of them or something, and killed those I could. Then iis unlocked.
If you are using VS 2017 to run your application, go under the 'Web' tab and change the port in the Project Url
D
Druid

Yeah, I agree, top answers are really pro solutions. Here is one for intermediates:

Solution Explorer

Right click on project select Unload project Again Right click and select Edit ProjectName.csproj Remove these 3 lines

<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:62940/</IISUrl>

Save and reload the project, and you are good to go.


I had enough with unloading - no need to remove any lines from .csproj file.
nice solution. before this had to restart the machine to solve this issue - so thanks for a great solution.
I didn't see the remove part, I just went there and changed the port and it workd
This resolved it for me. Nothing else worked, restart PC, the netsh, changing port. Just removing these 3 tags, fixed, many thanks!
This worked for me thanks. Ironically enough I had to run without debugging (Ctrl + F5) to get the error message that pointed me to this page for a working solution.
S
Spongman

try (as elevated administrator)

netsh http delete urlacl url=http://*:62940/

This actually worked for me. I believe I had to reserve the port in MSVS 2010 for some reason and then upgraded to 2013 (express) and began getting the error. I tried delete and then add (localhost -> '*') which didn't work. Then just the delete with no add and it worked.
This worked for me too, but only when run as Administrator. Otherwise it stated it couldn't find the file.
Try netsh http show urlacl to look for the conflicting entry.
This helped, but in my case was not sufficient. I also had to add the proper url back using netsh http add urlacl url=http://localhost:62940/ user=Everyone
URL reservation delete failed, Error: 2 The system cannot find the file specified.
A
Avrohom Yisroel

The ideal way to sort this out is to use the IIS Express tray icon to stop the web site that is causing the problem. To do this, click the little upward-pointing arrow in the right-hand end of the task bar and right-click the IIS Express icon. This will pop up a small window showing you the web sites that IIS Express is currently running...

https://i.stack.imgur.com/zgCZs.png

If you click on one of the items under "View Sites" you have the option to stop that site. Or, you can click the Exit item at the bottom of the window to stop all web sites.

That should enable you to debug in Visual Studio. When you start debugging again, IIS Express will automatically restart the web site, and should be able to allocate the port.

If that fails, you have to do it the dirty way. Open Windows Task Manager and kill the Microsoft.VisualStudio.Web.Host.exe*32 process, then you can run the project fine. Note that this will kill IIS Express completely, meaning that all web sites will stop, so you'll have to restart each one in VS if you want to debug any others. Try the pop-up icon method first tough as it's cleaner and safer.

Don't know if this answers your issue, but it works for me.

Update Thanks to JasonCoder (see comment below) for adding that on Win10, the process is Microsoft.VsHub.Server.HttpHost.exe


Microsoft.VsHub.Server.HttpHost.exe was what it was for me on Windows 7 with VS2015
This process runs again when I try to run the project. How do I get rid of it?
@nmit026 The process is supposed to run again, that's what runs your web site. The purpose of killing it is to free up the lock it seems to have on the port. When you next run, it restarts the process, and allocates the port correctly.
This is such a basic solution to what is otherwise a basic problem and I'm so glad someone put it out there.
C
Cayne

When using Visual Studio 2015 the solution can be a bit different to the previous answers. VS2015 creates a hidden folder .vs under the same folder as your solution file. Under this is a config folder containing applicationhost.config. Deleting this file (or the entire .vs folder) then starting VS2015 to recreate it can fix this error.


I didn't have to restart VS2015, just try to restart the application. Also, I had to click "Create Virtual Directory" in the web tab of the project properties pages.
My problem was that another project's .vs/config/application...config was using the port. Once I had removed the port from that application config I was good to go.
I had the same problem. I solved it by looking for this port in applicationhost.config. There should be a tag 'site' containing the same port as defined in project settings. If Visual Studio created some wrong site tags new, remove them.
This worked for me. I just deleted the config file, restarted VS and rebuilt the solution. IIS generated the config correctly this time.
Worked for me. I had corrupted my config file
B
Buggieboy

Got this error as well lately. Tried all the above fixes, but none worked.

To disable it, type services.msc in command prompt, then right click and disable Internet Connection Sharing. I edited the properties of it as well to disable at startup. Mine looks like so now: services capture screenshot.


In Windows 10 Anniversary edition it's called Mobile Hotspot and can be opened by typing e.g. "hotspot" in the Start menu and selecting Change mobile hotspot settings.
As Michael told, the problem was ICS. But you don't need to disable the service, just restart it and the port will be free.
damn! never thought sharing connection in win 10 could cause this issue. thanks man!
@DanielGenezini Ah yes! Thanks that did it! Been struggling with this for too long
How in tarnation did you figure this one out, @Michael.? This is one nasty bug. Thanks for sharing.
P
Philip Trenwith

I got the same issue when running my application from Visual Studio 2019 on Windows 10. After some time googling and trying various proposed solutions without success, I determined that the "Access Denied" error was a result of the port number my application uses (50403) falling in an "excluded port range".

You can view the excluded port ranges with the following command:

netsh interface ipv4 show excludedportrange protocol=tcp

After some more time googling I found that the two most likely culprits that create these exclusion ranges are Docker and Hyper-V. Docker was not installed on my computer but Hyper-V was.

My Solution

Disable Hyper-V: Control Panel-> Programs and Features-> Turn Windows features on or off. Untick Hyper-V Restart the computer. Add the port you are using to the port exclusion range: netsh int ipv4 add excludedportrange protocol=tcp startport=50403 numberofports=1 store=persistent Reenable Hyper-V Restart the computer

I added the port I am using to the exclusion list to ensure that I won't get this problem again after reenabling Hyper-V. After Step 4 and 5 when I viewed the excluded port range I can see that Hyper-V reserved a port range starting with the next port after my port.

https://i.stack.imgur.com/KaPsC.png

My application now worked perfectly!


Perfect Solution! I had docker installed which was causing the same problem. Thanks so much
just the command to identify exclusion ports so they can pick a free port is the simple solution to the port_is_in_use problem. No need for messing with Hyper-V or whatever other service is using/reserving the ports (and my big thanks for you help)
@HPWP7 Yes you are correct, the simple solution would be to pick another port. In my case I have to use port 50403 because the service gets consumed from external services which I have no control over. Therefore I need to reserve port 50403. (It is a pleasure, glad I could help)
I did not get it. The port you are trying to use, you are adding to the exclusion list, how will that help? Does that not mean your added port to the exclusion list is not free anymore and you can't use it? I may be missing something.
@ANewGuyInTown that is a good question, I have not looked into it in much detail, hence my answer may not be correct, however, I believe the account used to add the port to the exclusion list owns the port, in my case, it is the same account that is used to run the application, hence the port is available for my application
A
Arjan

This happened with me when I was trying to access my site from a remote location:

At first, applicationhost.config (VS2015) contained the standard:

<binding protocol="http" bindingInformation="*:64376:localhost" />

In order to access my site from a remote location within the network, I added (step 1):

<binding protocol="http" bindingInformation="*:64376:192.168.10.132" />

Then, I entered into CMD with Admin rights (step 2):

netsh http add urlacl url=http://*:64376/ user=Everyone

As step 3, I added it a rule to the firewall.

netsh advfirewall firewall add rule name=”IISExpressWeb” dir=in protocol=tcp localport=64376 profile=private,domain remoteip=localsubnet action=allow

Then, I got this error when trying to run the solution again.

Solution: I seemed to have done everything right, but it did not work until I ran netsh also for the existing localhost rule:

netsh http add urlacl url=http://localhost:64376/ user=Everyone

Now, it works again.


last command was exactly what I needed to get things working again
Thanks for this. This was exactly the same black hole I'd got myself stuck into after trying to access the site remotely.
S
ScaryLooking

I just had a similar issue. I'm not totally sure how to describe the actual fault but it seems like the hostname in the reservation is incorrect. Try this in an elevated command prompt...

netsh http delete urlacl url=http://localhost:62940/

... then ...

netsh http add urlacl url=http://*:62940/ user=everyone

and restart your site. It should work.


S
Sir CodesALot

I ran into this same error message, but it looks like it was produced from IIS Express. This article helped me resolve it

TL;DR

Run the following command from an Administrative command prompt:

> netsh http add iplisten ipaddress=::

@amy netsh configures Windows server roles/features. Essentially that enables http and ip listening for localhost. For those interested here's Microsoft's docs on it: technet.microsoft.com/en-us/library/…
Cheers @Micah, since then I had to undo this as all my locally configured IIS sites stopped working.. :/
Amendment: I just had to add 127.0.0.1 as an ip to listen on, all works now. Thanks for the solution again ;)
I don't know how but this helped me fix the error after several hours trying to fix it, thanks a lot!
Man you are a savior... you came as an angel and save my day. Thanks a lot...cheers
D
Dimitri C.

After trying a number of suggested solutions without success I just rebooted my PC. After that the problem didn't occur anymore.


As a small note - I tried every solution from here. I even tried shutting down and starting the PC again and it didn't work. Then a colleague suggested I actually use RESTART instead of SHUT DOWN and it worked. Poker face :| Using Visual Studio 2015 on WIndows 8.1 . This bug happens very often on various VS solutions I run locally.
T
TAHA SULTAN TEMURI

This is the only solution I found

net stop winnat

net start winnat

Thanks to Matt


Thank you! This solves it for me but I have to do it every couple of days. Does anyone know what is the root cause?
@TroyTurley , guess there might be a service in the background or a program which is changing the configuration
S
Sven Sönnichsen

I ended up with cleaning the project file (csproj) and the applicationhost.config (iis express) with all entries regarding iis express configuration. After that, it worked.


Cleaning out the applicationhost.config file worked for me. I just deleted all of the <site> entries in it. C:\Users\<USERNAME>\Documents\IISExpress\config\applicationhost.config
Yeah. This one worked for me in VS 2013. I cleared my website entry under <sites> and pressed Ctrl+F5. It says error unable to launch IIS Express. So, right click on the project, go to properties, under Web, next to project URL text box where http://localhost:3758/ specified, click on "Create Virtual Directory". Now Ctrl+F5 launched the site well.
C
Community

If you're having this after installing Visual Studio 2015 and you can see Error messages in System event log such as this: Unable to bind to the underlying transport for [::]:{your_port}. . The IP Listen-Only list may contain a reference ... then you might be missing a registry entry.

Run this under administrative command prompt: netsh http add iplisten ipaddress=:: to fix it.

I found the solution described in detail here


Even if you change your project port you need to run netsh http add iplisten ipaddress=:: thanks @Ignas
m
maxmantz

After all of the steps listed here failed for me I got it working by running VS2015 as administrator.


This is also the most likely cause if the URL it can't launch is a fake one you added into your hosts file
R
Renato Chencinski

This happened to me on Windows 10 and VS 2013. Apparently there is a maximum port number IIS Express handles. Ports above 62546 don't work for me.


I can't be sure if or what the max is. However, I was suffering from this error. I then deleted %userprofile%\Documents\IISExpress and edited my .csproj file, moving from port 63584 to 61111. After reloading, my project started just fine.
m
meJustAndrew

The error can be solved if you just restart Visual Studio. It has the same effect as restarting the Microsoft.VisualStudio.Web.Host.exe*32 process.


Non of restarts , even computer helped me. Not right solution for me.
For me it worked, try to update Visual Studio. You can try the other solutions too.
M
Marcus Höglund

Got the same issue where IIS express complained about http://localhost:50418/ and none of above solutions worked for me..

Went to projektFolder --> .vs --> config --> applicationhost.xml

In the tag <sites> I found that my web app had two bindnings registered.

<site name="myApp.Web" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\git\myApp\myApp.Web" />
    </application>
    <bindings>
        <binding protocol="https" bindingInformation="*:44332:localhost" />
        <binding protocol="http" bindingInformation="*:50418:localhost" />
    </bindings>
</site>

Removing the binding pointing to *:50418:localhost solved the issue.

Using VS2017 and IISExpress v10.


Hey, we're talking about IISExpress here, not IIS. I don't even have these 3 lines.
M
Matt Stannett

My issue turned out to be that I had SSL Enabled on the project settings. I simply disabled this because I did not require SSL for running the project locally.

In Visual Studio 2015:

Select the project in the Solution Explorer.

In the Properties window set SSL Enabled to False.

I was able to run the project.

In my situation I was getting an error about port 443 in use because this was the port set on the SSL URL for the project.


I had the inverse of this, I actually needed to enable SSL on my project. Good to see I'm not the only person who saw this error due to SSL.
I had to do this to set it to using ssl and then back to not (my app is not supposed to use ssl)
L
Loris

Running netstat -abn I noticed that the software "Duet Display" was reserving thousands of ports in the ~51000 range.

Closing it solved my problem.


This way is probably the best way, as it's not just desperately trying anyting to fix the problem, but instead helping to find the actual cause.In my case some other process sporadically picked the same port by chance that the IIS wanted to use, and this answer helped me to finally find the culprit.
A
Abdisamad Khalif

Sometimes this error my be another Visual Studio version running on the same machine.


D
Damitha

Go to the project "Properties" => "Web", and on the "Servers" section change the port to something else that is not used in and save it. You will be asked to created a virtual directory and click "Yes". Now run the project and it will work now.


This is the exact same answer as Francisco wrote 3 weeks prior.
D
Daniel Hilgarth

In my case it worked at first and after a while stopped working and IIS Express reported that the port was in use.
netstat -ab showed that Chrome was using the port. After I quit Chrome, it started working again.
I am not sure however, why Chrome would occupy that port.


This worked for me. I was using Browse With and switching between Firefox and Chrome without running the debugger. Something must have gotten hung up in the process. (Win7/VS2015)
h
hsobhy

This happened to me on Windows 7 and VS 2013 while viewing a project on the browser after build. I only had to close the browser "Chrome" then made sure that the port is not in use in my Network Activities using some utility (Kaspersky) then tried again and worked without any problems.


l
live-love

In Visual Studio 2015:

Find your startup page in your project (eg: mypage.aspx) , and right click on it.

Click on Set as Start Page.

Right click on the project.

Click on Properties.

Click on the Web Tab on the left.

In Project URL, enter a different port, such as: http://localhost:1234/

In Start Action, select Specific Page: mypage.aspx or select Specific URL: http://localhost:1234/mypage.aspx?myparam=xxx


O
Oğuzhan Sari

I write it for information.

Delete the file in the project.

After Clean>Build>Proje Start


k
k rey

I solved this issue by killing all instances of iexplorer and iexplorer*32. It looks like Internet Explorer was still in memory holding the port open even though the application window was closed.


w
workabyte

I had this issue with JetBrains Rider, specifically for port 80 and 90 bit it was working with other ports as well as visual studio.

after running as admin this resolved the issue.


That's because you're trying to open a port < 1024. Those are service ports.
yes that is true but running as admin does enable you to bind to these ports
Yes, but you shouldn't be binding those ports as admin. It's dangerous.
M
Morpheus

In Visual Studio 2019 Just remove Debug profile and create new one Do the Trick

Go to Project properties In debug tab try first Changing ports Web Server Settings if Changing ports not worked then Remove Debug Profile and Create new One-Warning Make Sure You Know Previous Settings


D
Devator

What worked for me is disabling all other network adapters, except the one I'm currently using. The event in event viewer was: Unable to bind to the underlying transport for [::]:50064. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine. The data field contains the error number.

Since I have VMware Workstation, Docker (and thus Hyper V) some VPN clients, I have a lot of network interfaces.