Visual studio 2017 "Unable to connect to web server 'IIS Express'"

Visual StudioIis Express

Visual Studio Problem Overview


If I attempt to launch my .net core app I get this message. I realize there are many posts out there claiming to fix this but I have tried every method they suggest and none are working.

If I go into the project properties under debug and change the port, then it will connect 1 time. Then if I attempt to connect again, it will give me the same error again. I can then switch the port back to the original and it will load one time, then it will fail any time beyond that, until I switch it again. Anyone have any ideas or fixes they used?

Thanks!

Visual Studio Solutions


Solution 1 - Visual Studio

I had this problem. There is a hidden folder in directory of project that name is '.vs'. Close the Visual Studio and delete this folder. The problem will be solved.

Solution 2 - Visual Studio

I installed core 2.0 and updated VS 2017 to 15.4.3 today, had the same error.

I ended up changing the application to run on a different port, it worked for me.

I have tried to delete the vs folder but did not work.

Hope it helps.

Solution 3 - Visual Studio

I know there is already an accepted answer to this question, but none of the solutions worked for me and my solution may help someone. I am using VS2017 with an ASP.NET Core 2.0 Razor Pages project.

The error just started appearing for no obvious reason, and I tried the solutions posted here.

I ran the web app from the command line using the dotnet run command to see if that would bring up any meaningful errors, and there was a warning about the URL not being correctly bound. I looked in my projects Properties\launchSettings.json file and noticed that the applicationUrl properties were different.

enter image description here

  1. Change the values for applicationURL so they are the same
  2. Close the project and close VS
  3. Delete the hidden .vs folder (as mentioned in the accepted answer)
  4. Start up VS as Admin

Your app should work fine.

Solution 4 - Visual Studio

I was having the issue on Visual Studio 2019 with a clean branch from master. Restarting the PC solved the problem.

My college said he is having the problem about 2 times a month and other tries for solutions did not work.

Solution 5 - Visual Studio

It could also just be that there are iisexpress.exe processes hanging around in task manager which were running on the same port.

I've just found a couple and killing them solved this problem for me without needing to delete any .vs folder or changing ports or anything like that.

Solution 6 - Visual Studio

I gave up, and chose to run the project as self hosted, instead of 'IIS Express' in the play/run drop-down box.

enter image description here

Solution 7 - Visual Studio

In my case, the problem was caused by the port for HTTP and HTTPS being the same:

enter image description here

The ports must be different:

enter image description here

Solution 8 - Visual Studio

In a solution if you have multiple projects using ASP.NET Core in Visual Studio 2017 and you are trying to use the same port number you will get this error. You must have unique port assignment in your solution.

Go here in your project: Properties/launchSettings.json open this file and edit the port numbers here. Note: This is where you change the SSL port (two places).

Reason: VS/IIS Express maintains bindings to all the ASP.NET Core projects in your solution that use IIS Express as the server. For example if you use Kestrel or some other server you will not have this problem. VS creates a new port for each app when it is created in the solution to ensure you do not have port conflicts.

If you are trying to use Azure AD registered applications reply ports and trying to "reuse" your app registration, you might think to simply change the "app's" port so that you don't have to register it in Azure; this will not work. If you are just testing apps and want to reuse a registration then you must make sure that the app you are currently working on is the ONLY one on the port - manually. If you need to test two or more apps then you must register them in Azure AD individually as you would in production.

Solution 9 - Visual Studio

What worked for me and it is really simple:

  1. Right-click project
  2. Properties
  3. Debug
  4. App URL: change port to 5000

Done, hope helps someone.

Solution 10 - Visual Studio

Changin https -> http in my applicationUrl solved this issue in my case.

Solution 11 - Visual Studio

I have solved this issue by adding exclusion to file devenv.exe in windows defender (anti virus, Win10)

how to know this is the issue; when you load project defender will notify in notification unauthorized changes blocked. if this is the issue just add the exception as above mentioned.

Solution 12 - Visual Studio

For me above solutions did not work

But changing the IIS Express Bitness to x64 worked

Solution 13 - Visual Studio

I encountered this issue. Running VS in admin mode solved this issue for me.

Solution 14 - Visual Studio

Go to properties - select debug tab - change the App URL - e.g. to http://localhost:57520/

Something else can be running on your port that interferes.

This worked for me!

Solution 15 - Visual Studio

For me with VS2019, faced this same issue on start running our project. So right clicking on IIS Express icon in notification pane near by DateTime pane in our laptop/Desktop. It will show up all running application, at last can find Exit. Click Exit there and run your project should work. That worked for me, without closing VS19 project.

Solution 16 - Visual Studio

After playing with netsh configuration trying to make the server accessible from outside, I added a new iplisten entry. The IISExpress showed the error Unable to connect to web server 'IIS Express' which was fixed after deleting the iplisten entry using:

netsh http delete iplisten <ip-address>

You can view the current list of iplisten entries using

netsh http show iplisten

They require running an elevated (administrator) command prompt.

It seems like IISExpress has no error message in this a case.

Solution 17 - Visual Studio

  • If you're hard-coding a specific IP address (not localhost), check that it hasn't changed.

Solution 18 - Visual Studio

Tried all. didn't work above. changing host in applicationhost.config fixed.

change localhost to 127.0.0.1

<binding protocol="http" bindingInformation="*:50740:127.0.0.1" />
<binding protocol="https" bindingInformation="*:44381:127.0.0.1" />

Solution 19 - Visual Studio

It works after I reenter username and password for the application pool's identity account

Solution 20 - Visual Studio

Setting "Enable SSL" to false in project properties\Debug section worked for me.

Solution 21 - Visual Studio

It may not completely direct your case, but I just had to restart my (windows) system. The https://stackoverflow.com/a/50507657/182542">diagnosis</a> of @Turneye may very well be the reason and his solution might accomplish the same result.

Solution 22 - Visual Studio

I added the localhost option on the applicationhost.config file and run visual studio as administrator and it worked for me.

    <binding protocol="http" bindingInformation="*:6873:localhost" />
    <binding protocol="https" bindingInformation="*:44320:localhost" />
    <binding protocol="http" bindingInformation="*:6873:192.168.137.1" />

Solution 23 - Visual Studio

Some times running visual studio as administrator solves this issue.

Solution 24 - Visual Studio

For me worked by changing the applicationUrl in launchsettings.json file to different port number and that url to be same for all places inside this file.

Solution 25 - Visual Studio

In my case (VS 2019), all I have to do is Rebuild the code before I re-run the app after each code modification.

P.S. I am coding server-side Blazor.

Solution 26 - Visual Studio

If you've used netsh http add urlacl url=http://localhost:<port>/ user=everyone to add a specific url acl using the problem port then you'll need to delete it with netsh http delete urlacl url=http://localhost:<port>/ user=everyone.

Another solution is to run Visual Studio as an administrator which allows it to override the urlacl.

Solution 27 - Visual Studio

I was facing the issue multiple times in VS2019, then I realized when I make small edits and restart the IIS Express this problem is more pronounced. Some of the discussion above about ports make me think since I was closing the app by just closing the browser. So I believe the port was not released and it failed the start next time around. I started closing the debug by clicking the "Stop Debugging" button in the VS2019. The issue didn't occur again for me.

Solution 28 - Visual Studio

I solved this by restart my laptop.

Solution 29 - Visual Studio

Rebuilding the solution fixed this problem for me.

Solution 30 - Visual Studio

For those of you using .Net Core 3.x and still struggling, like myself, I finally after days of searching found a hint to the problem https://weblog.west-wind.com/posts/2020/Jan/14/ASPNET-Core-IIS-InProcess-Hosting-Issues-in-NET-Core-31.

> In .NET Core 3.x InProcess hosting for IIS is the default. OutOfProcess hosting externally runs Kestrel.exe and has IIS proxying requests into the external Kestrel HTTP host. InProcess hosting uses a custom IIS Module that bootstraps a custom .NET Core host right into the IIS host process which provides better performance and a smaller footprint.

Changing to "Out of Process" (Right Click Project > Properties > Debug > Web Server Settings > Hosting Model), closing visual studio, deleting the hidden .vs folder (as described in previous comments), and then running IIS Express in VS finally worked. If you ever change it back to "In Process" for testing and it doesn't work, you'll have to delete the .vs folder again after you change it back and close the project.


If you're like me and that got you over one hurdle and into another....

My next issue was i was getting this error This webpage is not available (with error code "ERR_CONNECTION_RESET") when running a request to ping the server in powershell (Invoke-WebRequest -Uri:https://localhost:{port}/{endpoint}). This thread mentioning the error lead me to a thread that mentioned a missing iss express development cert, which mentions solving it by running ./IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:{port}/ -UseSelfSigned in the IIS Express program files directory in an admin powershell terminal.


I'm also gonna post my first issue here when trying to run IIS Express from Visual Studio, which was Cannot find C:\Program Files\IIS Express\iisepxress.exe. IIS Express was for some reason installed not only in my Program Files (x86), but in my second drive (D:\Program Files (x86)). After realizing that there is just no way to change where Visual Studio is looking for IIS Express (even though it's also installed on the D drive), I uninstalled IIS Express (which is probably how my dev cert got removed), in RegEdit changed my Program Files directory back to the "C\Program Files" folder (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion > ProgramFilesDir key), and reinstalled IIS Express from Microsoft.


Finally, I can run my .Net Core API locally using IIS Express.

Good luck all!

Solution 31 - Visual Studio

Your port is blocked for that specific user. Either change the port or user, or otherwise allow that port for that user. Admins usually have all the rights.

Solution 32 - Visual Studio

One of the reason is that port is used by other application or system. Follow the steps to identify the port issue.

  1. You need to verify that the port is available or not.

    • replace your port number in the command and fire this in administrative command prompt or in any other shell. i.e. I was using 1344 port.

> netstat -ano -p tcp |find "1344"

enter image description here It will print the information if any process use the given port. you will get process id (PID) in last column of the above command's result

  1. Go to Task Manager -> Details Tab -> check the process by Id ( add the PID column if it's not visible )

enter image description here

  1. As the port is occupied by a system process, we should change the port in our project.

    else if it is other program, you may kill the process or change the port in that program if possible.

Solution 33 - Visual Studio

Delete IISExpress Logs of the solution under path C:\Users[user name]\Documents\IISExpress\Logs and start running the project it worked fine.

Deleting .vs folder didn't work for me, neither the updates

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDevDevDevView Question on Stackoverflow
Solution 1 - Visual StudioMohammad TaherianView Answer on Stackoverflow
Solution 2 - Visual StudioTofuninja173View Answer on Stackoverflow
Solution 3 - Visual StudioDomBurfView Answer on Stackoverflow
Solution 4 - Visual StudioOnat KorucuView Answer on Stackoverflow
Solution 5 - Visual StudioTurneyeView Answer on Stackoverflow
Solution 6 - Visual StudioilansView Answer on Stackoverflow
Solution 7 - Visual StudiodemonicdaronView Answer on Stackoverflow
Solution 8 - Visual StudioLarry AultmanView Answer on Stackoverflow
Solution 9 - Visual StudioMarchalPTView Answer on Stackoverflow
Solution 10 - Visual StudioInfernumDeusView Answer on Stackoverflow
Solution 11 - Visual Studioadnan umarView Answer on Stackoverflow
Solution 12 - Visual StudioirfandarView Answer on Stackoverflow
Solution 13 - Visual StudioKrishna kishoreView Answer on Stackoverflow
Solution 14 - Visual Studiouser1836609View Answer on Stackoverflow
Solution 15 - Visual StudioSyed MohamedView Answer on Stackoverflow
Solution 16 - Visual StudioAlex PandreaView Answer on Stackoverflow
Solution 17 - Visual Studiojv_View Answer on Stackoverflow
Solution 18 - Visual StudioMuhammad Abrar AnwarView Answer on Stackoverflow
Solution 19 - Visual StudioAdelaide BrightonView Answer on Stackoverflow
Solution 20 - Visual StudiokayView Answer on Stackoverflow
Solution 21 - Visual StudioAGuyCalledGeraldView Answer on Stackoverflow
Solution 22 - Visual StudioDonayam NegaView Answer on Stackoverflow
Solution 23 - Visual StudioAbdulhakim ZeinuView Answer on Stackoverflow
Solution 24 - Visual StudioRakeshkumar DasView Answer on Stackoverflow
Solution 25 - Visual StudioJohnny WuView Answer on Stackoverflow
Solution 26 - Visual StudioN-ateView Answer on Stackoverflow
Solution 27 - Visual StudioisubodhView Answer on Stackoverflow
Solution 28 - Visual Studiosean717View Answer on Stackoverflow
Solution 29 - Visual StudioStarLordView Answer on Stackoverflow
Solution 30 - Visual StudioNitrokittyView Answer on Stackoverflow
Solution 31 - Visual StudioQasim AliView Answer on Stackoverflow
Solution 32 - Visual StudioNirav MistryView Answer on Stackoverflow
Solution 33 - Visual StudioSadeeshView Answer on Stackoverflow