Sarek
Sarek

Reputation: 3648

ASP.NET 5 MVC: unable to connect to web server 'IIS Express'

What I'm doing:

Deleting applicationhost.config, located in Documents\IISExpress\config, doesn't change the error message. (There's also an IISExpress folder in program files and program files (x86).)

Something I noticed, and I don't know if it's a problem:

Referenced file 'lib/jquery-validation/jquery.validate.js' not found.

I got a dump with rawcap but I don't notice much in there. Some of what was there:

"Framework":{"FrameworkName":"DNXCore,Version=v5.0","FriendlyName":"DNX Core 5.0","ShortName":"dnxcore50","RedistListPath":null}

I don't notice a problem, but I have the network data if that can help figure out why I cannot connect to the web server. I get a RST,ACK immediately so I'm guessing the port is closed and whatever this web server is, isn't being setup.

More on this problem: 800700c1 error from /trace:error

I've tried:

Upvotes: 359

Views: 454237

Answers (30)

Khalid
Khalid

Reputation: 367

Maybe this is late but in my case I needed to change the port number I am using in lunch file as it was occupied by some other service

Upvotes: 0

Patrick Thorpe
Patrick Thorpe

Reputation: 380

I had this issue, and it turned out to be because the server was failing due to unapplied database migrations.

A simple Update-Database package manager console command for EF Core fixed this for me.

Upvotes: 1

MaciejW
MaciejW

Reputation: 69

Something that worked for me based on this

Make sure iplisten is configured to 0.0.0.0

If the IP listen list is not configured, this issue may occur (caution, I have no idea why).

Check netsh to ensure there is an entry for 0.0.0.0 In command prompt type:

netsh http show iplisten

There should be:

enter image description here

If it does not appear on your prompt, add the correct correct netsh rule. You'll need an admin cmd.exe or admin PowerShell for this.

In command prompt type: netsh http add iplisten ipaddress=0.0.0.0

Upvotes: 0

Gabe
Gabe

Reputation: 965

If you made it this far, you are clearly desperate. Good luck to you and your pursuit to find happiness again.

Did you just merge code in from another branch? Did you accidentally merge in duplicate entries in the Program.cs file? (I'm using .NET Core 6)

For me, there were duplicate entries for both:

builder.Services.AddDatabaseDeveloperPageExceptionFilter();

and

builder.Services.AddDefaultIdentity...

Not sure which one caused the issue but fixing the merge resolved the problem.

Upvotes: 0

Saleh Sayeem
Saleh Sayeem

Reputation: 119

-> close visual studio -> delete .vs file -> delete launchsettings.json

restart visual studio...

hope that solves your problem

Upvotes: 0

Prince
Prince

Reputation: 163

I disabled the SSL in debug properties and then enable it again. It worked like charm.

If you can afford to restart your system, do it.

Upvotes: 0

StarLord
StarLord

Reputation: 1003

Ending the IIS worker process in the task manager helped me solve this issue.

Upvotes: 0

Victor Stagurov
Victor Stagurov

Reputation: 4756

After installing Update 2 for Visual Studio 2015 I started getting the same error. I tried everything above with no luck. However, I found a solution that works for me:

  1. Delete YourSolutionFolder\\.vs\config\applicationhost.config file (note: .vs is a hidden folder)
  2. Open Visual Studio, right-click on web site > Properties > Debug tab > Web Server Settings > App URL - change port number.

If you have IIS configured to use the same port, (stop the application / use different port) and try again.

Upvotes: 435

pigeon
pigeon

Reputation: 161

My issue was similar to what others have said, but a slightly different flavor that may help someone. I am running VS 2019 and .NET 5.0 ASP.NET.

TL;DR

Ensure socket bindings in .vs\...\applicationhost.config and launchSettings.json for the project and selected configuration the match the current enabled NICs :).


Details

I had been mucking with my .vs\...\applicationhost.config and launchSettings.json to be able to host not just on localhost, but on my NICs IP address/port (socket) for testing on another device. Recently, I added a second socket to have a colleague test something over a VPN. When the VPN was not connected, I could not start IIS.

I reconnected the VPN, and everything started working again. Then after disconnecting the VPN, I updated launchSettings.json (and restarting VS2019), but forgot to update the bindings in applicationhost.config. I believe IIS Express still worked hosting one more time, but the 2nd time it would not. It was then that I realized I still had the VPN socket in the applicationhost.config bindings. I updated it, restarted VS2019 and all was well.

Upvotes: 0

Dean P
Dean P

Reputation: 2225

Depending on what caused the issue the solution may be far more simple than those proposed above. I have seen this fault arise when I renamed my project directory or a folder within which it is contained. Renaming the folder structure back to what it was solves the error for me. Ofcourse this isn't the perfect solution in the event you would genuinely like to change the folder structure.

Upvotes: 1

Daniaal
Daniaal

Reputation: 922

I had this issue on .net core 2.1, visual studio version 15.9.6. When i deleted the .vs folder, i reopened visual studio and the problem was still there. The solution that worked for me below:

  1. Delete .vs folder (it is a hidden folder).
  2. Restart Computer.

Other Solutions:

  • Close Visual Studio, delete bin and obj folders from the project folder. Open Project then rebuild solution.
  • Try running Visual Studio as Administrator.
  • Clean Solution then rebuild
    1. Clean Solution. 2) Exit Visual Studio. 3) delete .vs folder 4) Re-open Visual Studio
  • Restart machine (if you can afford to)

Upvotes: 51

Benzara Tahar
Benzara Tahar

Reputation: 2205

If you can afford to restart your machine then do it 👌, this fixed my issue after almost an hour of trying to fix this issue with no hope 🤯.

Upvotes: 9

Joe Eng
Joe Eng

Reputation: 1224

Instead of debugging with the IIS Express profile, I recommend debugging with the profile named after your project. It works fine for me. I'm never going back to IIS Express!

Upvotes: 1

Kangaxx
Kangaxx

Reputation: 81

I was trying to launch the app on the URL "http://192.168.0.1:4000/", and the above answers didn't help. Finally, I added the *:4000:localhost HTTP binding to the .vs/.../applicationhost.config, so now the binding section looks like this:

<bindings>
  <binding protocol="http" bindingInformation="*:4000:localhost" />
  <binding protocol="http" bindingInformation="*:4000:192.168.0.1" />
</bindings>

And it did the trick

Upvotes: 0

Horev Ivan
Horev Ivan

Reputation: 268

Change port manually for http and https (or disable https)

Upvotes: 0

Qjot
Qjot

Reputation: 11

I've tried all listed here, but nothing really helped. Solution was simply to change IIS server port listening (apparantely port 80 was already taken, but the error message didn't said so).

Btw. in my case port 80 was taken by main windows service which I couldn't stop/kill...

From main ISS manager, go to Default Web Site and edit bindings (below screenshot is in Polish - hope it helps anyway)

Edit IIS bindings

Then I've changed port 80 from http binding to (whatever you like) 8081 as below:

Change Http port to whatever you like

So after that all projects(web page, apis) started working correctly.

Upvotes: 0

Quinton Smith
Quinton Smith

Reputation: 2670

Copied my comment to an answer by request.

For Net Core 2.2 project - After a MASSIVE struggle and trying everything from deleting .vs folder, deleting IIS Express configs, changing port numbers, changing bindings, and to running VS as admin I FINALLY fixed issue by

  1. closing VS,
  2. deleting launchSettings.json
  3. opening VS which re-generated launchSettings.json.

It was not apparent that the file was corrupt or incorrect or even when it changed to cause failure.

Upvotes: 41

dwoodard
dwoodard

Reputation: 3119

Exit VS and delete the (project)\.vs\applicationhost.config file. Restart VS. It should start working.

Upvotes: 292

Syles
Syles

Reputation: 135

As Svenmarim already stated, this mostly occurs because the ip adress is already in use. This answer and its comments from the visualstudio developer community pointed me to the right direction. In my case i was trying to access my local IISExpress instance from my local network and therefore binded my ip adress with the same port which uses my IISExpress instance via
netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone
After removing this binding via
netsh http delete urlacl url=http://192.168.1.42:58938/
it worked again.

Upvotes: 0

Day&#225;n Ruiz
Day&#225;n Ruiz

Reputation: 680

Restart your computer, that will work, at least it did it for me.

Upvotes: 1

Rohan Rao
Rohan Rao

Reputation: 2603

For me it was very easy.

  1. Clean the solution
  2. Re-build the solution.
  3. Run it Ctrl + F5 (Run without Debugging)

Upvotes: 0

Mojtaba Nava
Mojtaba Nava

Reputation: 878

First: remove .vs folder from project (aside .sln file), then open project.

Good luck

Upvotes: 2

Kanna Reddy
Kanna Reddy

Reputation: 345

Faced the issue when reinstalled Windows on C: Drive, but my Visual Studio projects were intact on E: drive after the installation. I have resolved the issue by removing .vs folder in the visual studio project folder.

Upvotes: 0

Mikael Holmberg
Mikael Holmberg

Reputation: 101

If you don't want to reboot your can, a solution is to manually attach the debugger. In my case the application is launched but visual studio fails to connect to the iis. In Visual Studio 2019: Debug -> Attach to process -> filter by iis and select iisexpress.exe

Upvotes: 0

Harsh
Harsh

Reputation: 143

If you are using VS 2017 or VS 2019 with ASP.Net Core, you can directly go to launchSettings.json under Properties folder and just change the Port number of applicationUrl key for iisSetting.

enter image description here

Upvotes: 5

ManiVI
ManiVI

Reputation: 590

in my case it was pulse secure vpn tripping up Visual Studio 2019 community edition for some reason ! workaround is to suspend vpn, start debug solution, then resume vpn connection.

Upvotes: 1

Pelais
Pelais

Reputation: 1737

With the Visual Studio closed, I deleted the temporary folder iisexpress in: C:\Users\<your_user>\AppData\Local\Temp\iisexpress.

Upvotes: 1

samneric
samneric

Reputation: 3218

In my case this error was caused because I was running Docker.

Make sure the port you are trying to host on is not in a Port Exclusion Range by running the following command in cmd/powershell session:

netsh interface ipv4 show excludedportrange protocol=tcp

I tracked this down after reading through this stackoverflow question:

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

Steve

Upvotes: 0

In my case (using ASP.NET Core 3.1 and Visual Studio Professional 2019), I've seen this twice and in both cases fixing it was as simple as rebooting my PC.

I strongly suspect, but can't prove, that this could also be accomplished by restarting only a specific process (like in @Codenova's answer).

Upvotes: 1

Pal
Pal

Reputation: 23

if you copy the project from other pc. you can try

netsh interface ipv4 show excludedportrange protocol=tcp

to check the Start Port to End Port that is allowed to use on you computer

enter image description here

Upvotes: 1

Related Questions