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

346,257

Solution 1

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.

Solution 2

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

Solution 3

Try using a different port. I just set up a new Core 1.0 RC1 project and got the same error.

  • Right click web project
  • Debug tab
  • Toggle Enable SSL off and on again, it should generate a new random port
  • Copy the SSL URL and paste into Launch URL box
  • Run the project

Worked for me (TM).

Answer from: https://stackoverflow.com/a/28650554/134761

enter image description here

Solution 4

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)

Solution 5

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.

Share:
346,257

Related videos on Youtube

Sarek
Author by

Sarek

Updated on July 08, 2022

Comments

  • Sarek
    Sarek almost 2 years

    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:

    • deleting applicationhost.config (and changing port number)
    • running visual studio as administrator
    • deleting IISExpress folder in Documents (changes error message until the folder is reinstalled)
    • toggling ssl off and on, copying url to launch box. (note: I'm not using ssl)
    • clearing all sfc /scannow errors
    • starting iisexpress with x86 version and 64-bit version
    • mariocatch
      mariocatch about 8 years
    • Hazem Torab
      Hazem Torab about 8 years
      try when you open visual studio right click and open as administrator..
    • Sarek
      Sarek about 8 years
      I'm trying all suggestions people give me even if I have tried before.
    • Sebastian 506563
      Sebastian 506563 about 8 years
      can you open new project an check if this is working? Restart PC? Move project to other directory
    • Sarek
      Sarek about 8 years
      Thank you but that also didn't work.
    • Andrei
      Andrei about 8 years
      @Sarek, were you able to find a solution? If so, do you mind answering your own question? We are having the same issue.
    • Sarek
      Sarek about 8 years
      I tried everything and cleared everything up with sfc /scannow. Then I gave up and just did a repair install. That worked, but I have no idea what the problem was.
    • nam
      nam over 7 years
      @Sarek In my case just closing and re-opening the VS2015-Update3 worked. I'm using ASP.NET core 1.1. Maybe, with new version, steps I took was good enough to resolve the issue or different users have different solutions depending on their VS configurations etc.
    • Lex Li
      Lex Li about 6 years
      ASP.NET Core in Visual Studio 2015 is not considered as a fully supported scenario, so such issues are expected. All users should migrate to Visual Studio 2017, or switch to Visual Studio Code.
    • Lamar
      Lamar over 5 years
      This happens to be every once an a while after changing absolutely nothing. The issue has been around for awhile and MSFT still hasn't worked it out. Hate them for it and their support sucks. Screw them.
    • JGilmartin
      JGilmartin almost 5 years
      this article solved my issue -> overengineer.net/…
    • Mahmut EFE
      Mahmut EFE over 3 years
      Close Visual studio. Try to delete Bin, Obj and vs folder. After that problem should resolve, It worked for me.
    • VSO
      VSO about 3 years
      Last time restarting worked. This time, it didn't. Deleted project, re-pulled. Didn't help. Delete project, re-pulled, restarted. Works. Not sure, but not worth spending more time on.
  • René Sackers
    René Sackers about 8 years
    Man, my error came back, found this as well on another site, but it just keeps giving the damned error. Pissing me off. I'd run the web console, but that doesn't have a watcher, so that I can just ctrl + s, refresh.
  • René Sackers
    René Sackers about 8 years
    Omg, it works. I deleted the IISExpress folder in my documents, then I deleted that file, then I started getting this error, but the accepted answer was the solution: stackoverflow.com/questions/33166403/… and now it's working :|
  • aruno
    aruno over 7 years
    I had to do this to increment the port number. my original post was 'stuck' and I don't have time now to reboot or figure out how to fix it
  • Michael
    Michael over 7 years
    Just installed Update 3, started getting this error after adding a new class to a Core project. This solution worked for me.
  • EKanadily
    EKanadily over 7 years
    It worked but only when i used port 60000 . port 6000 returned error : unsafe port.
  • Shiham
    Shiham almost 7 years
    May be explain you answer a bit. Just killing the process might not be the answer here. And what after?
  • mlienau
    mlienau almost 7 years
    This worked for me in VS2017, without having to change the port.
  • wisetap.com
    wisetap.com almost 7 years
    After doing this for me was needed run Visual Studio as Administrator, and worked, thanks!
  • Bart Mensfort
    Bart Mensfort about 6 years
    Especially the RUN AS ADMINISTRATOR is important for me. (although I have Asp.net Core 2.0 VS2017.
  • Lex Li
    Lex Li about 6 years
    When launchSettings.json is automatically generated or updated by VS, the applicationUrl should have / in the end. More info can be found in blog.lextudio.com/…
  • Lex Li
    Lex Li about 6 years
    Only administrator permissions allow the application to bind to a port number smaller than 1024. That's why 6767 works for you.
  • FindOutIslamNow
    FindOutIslamNow almost 6 years
    Deleted the whole .vs folder and worked for me, just that
  • Tonmoy
    Tonmoy almost 6 years
    Restarting VS2017 didn't fix but restarting the computer fixed it for me. Didn't need to change the port or delete the folder. Hope it helps others.
  • Lamar
    Lamar over 5 years
    Changing the port number is annoying af when you have saved testing requests
  • MercifulGiraffe
    MercifulGiraffe over 5 years
    This worked for me, but also only after I restarted VS in Administrator mode.
  • Muhammad Musavi
    Muhammad Musavi over 5 years
    Non of these solutions worked for me, If you have installed default Windows IIS (Which comes with your windows) and have access to it, try to use it, that solved my problem, simply Add new website or new application there and it's done, anyway it's weird that IIS Express is unable to open up the page. If you need to trace it, just attach it to a process using ctrl + alt + p short keys and check Show process for all users and select w3wp.exe (sometimes need to refresh the website to find w3wp.exe) and then hit the Attach button.
  • Prolog
    Prolog about 5 years
    This is not a solution, but a workaround. Your answer suggest using different server - Kestrel - while OP clearly is trying to get IIS-Express to work.
  • laggingreflex
    laggingreflex about 5 years
    For me it was .vs\config\<MyProject>\config\applicationhost.config
  • Meir
    Meir about 5 years
    After three days of plucking hair, this solution helped me. Thank you
  • GMc
    GMc almost 5 years
    This is a bit unclear, what do you mean by "just change all port numbers to new of any work8ng series"? Can you provide more detail as to how this answers the OP or which parts of the OP it answers? Do you have a working example you can post?
  • CodyBugstein
    CodyBugstein almost 5 years
    where do you see web site that you need to right click on?
  • Madhusudhan V Indian
    Madhusudhan V Indian almost 5 years
    I mean , change project deployment ports , for example local host:55314 like that ... Generally default is 44304 like , so change that ... Then all starts working.
  • Sentinel
    Sentinel almost 5 years
    Worked for me, but had to do it twice!
  • Robert Bratton
    Robert Bratton almost 5 years
    I was able to do this by shutting down only Visual Studio, deleting the .vs folder, stating Visual Studio again.
  • Daniaal
    Daniaal almost 5 years
    Yeah it works for some not in my case though. No idea why it didn't work. The only thing that did was restarting my computer.
  • Sonali
    Sonali almost 5 years
    It works but no need to restart computer.Only close the Visual Studio. Delete the .vs folder and again start the visual studio. I am using visual studio community 2019
  • Daniaal
    Daniaal almost 5 years
    Ah ok, glad it worked. Mine was weird cause when i opened the message, it would still not work and after restarted it worked. Must be a lock and configuration gone wrong in a file in the vs folder.
  • Dan Orlovsky
    Dan Orlovsky almost 5 years
    VS 2019 - .vs\config\<MyProject>\config\applicationhost.config worked for me, too.
  • Ulysses Alves
    Ulysses Alves almost 5 years
    I'm running VS as Admin but I still get the same problem.
  • johnbt
    johnbt over 4 years
    Got this after a bluescreen. Had to delete .vs folder and restart the computer. Restarting visual studio was not enough.
  • Daniaal
    Daniaal over 4 years
    Glad it worked for you! Never happened to me since but there may have been a fix. I'm now running the latest version of Visual Studio.
  • Daniaal
    Daniaal over 4 years
    @SarahLissachell Amazed me too! Took me hours to figure it out so i am glad it helped :)
  • Matt Searles
    Matt Searles about 4 years
    Changing the port number did the job for me
  • WeisserHund
    WeisserHund about 4 years
    This was the solution for me, Thanks
  • MedievalCoder
    MedievalCoder about 4 years
    Although a manual clean often times does help, it won't resolve the issue in this case as the problem resides in the applicationhost.config file and is most likely caused by trying to use the same ip address twice
  • EJoshuaS - Stand with Ukraine
    EJoshuaS - Stand with Ukraine about 4 years
    Didn't work in Visual Studio 2019 - it just used the same port each time.
  • dxk3355
    dxk3355 about 4 years
    Using the same software as you. I've done reboot, deleting vs folder, deleting bin/obj, start as admin, change the ports, reinstall IIS Express, and nothing has fixed this. It seems to kick off a refresh IIS Express instance every time I start the debugger then forgets itself.
  • angularsen
    angularsen about 4 years
    @EJoshuaS-ReinstateMonica I believe this has changed a lot. Take a look at how your Startup class is configured and what appsettings.json files you have. There is also Properties\launchSettings.json to launch different profiles locally. docs.microsoft.com/en-us/aspnet/core/fundamentals/… dejanstojanovic.net/aspnet/2018/december/…
  • Quinton Smith
    Quinton Smith about 4 years
    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.
  • samneric
    samneric about 4 years
    My steps were compressed to: 1) Clean Solution. 2) Exit Visual Studio. 3) delete .vs folder
  • Daniaal
    Daniaal about 4 years
    @samneric Thanks for that, i'll add you solution to the answer :)
  • samneric
    samneric about 4 years
    actually, it worked once then the issue came back lol. My situation ended up being caused by Docker. This ended up being the ultimate solution... stackoverflow.com/a/61579820/558509
  • Mitulát báti
    Mitulát báti almost 4 years
    VS shouldn't be run with Admin rights. If you can solve a problem only by starting in Admin mode you're probably doing something wrong.
  • krunal.cp
    krunal.cp almost 4 years
    The solution worked. Thanks :) How about DELETE the .git folder as well?
  • Patrick Borkowicz
    Patrick Borkowicz almost 4 years
    Seems to happen randomly for me. Only a reboot fixes it. In the case of ASP.NET Core projects I usually just run the project without IIS Express, which is the green drop down arrow next to the 'play' button in VS, switch to <projectname>. As far as I know this is the same as running dotnet build and dotnet run from the command line.
  • yogihosting
    yogihosting almost 4 years
    Also .vs folder is a hidden to un-hide it first.
  • Anand Murali
    Anand Murali almost 4 years
    Thank you @QuintonSmith. Your solution worked for me in .NET Core 3.1 as well.
  • Alex Pandrea
    Alex Pandrea over 3 years
    to highlight the change: http instead of https
  • Alex Pandrea
    Alex Pandrea over 3 years
    I subscribe: after playing with netsh configuration trying to make the server accessible from outside I encountered this problem. Forgot what I did and tried almost all the other answers until deleting the iplisten entry as described here. It seems like IISExpress has no error message in such a case.
  • Amir Hajiha
    Amir Hajiha over 3 years
    You are not a start, but a superstar! Thanks it worked
  • Sanket Sonavane
    Sanket Sonavane over 3 years
    Thanks Quinton you saved the day
  • Sk Shahnawaz-ul Haque
    Sk Shahnawaz-ul Haque over 3 years
    Thanks @QuintonSmith, your solution is working in Visual Studio 2019 Preview for ASP.NET Core 5 (.NET 5 RC2 SDK) as well.
  • isierra
    isierra over 3 years
    First try I deleted .vs folder and it didn't worked. Second try I deleted the folder and restarted the computer, and it is working perfect! Thanks
  • Abdullah Tahan
    Abdullah Tahan over 3 years
    keep in mind with will delete all the previous setting like swagger or docker so just make a copy of the old one @QuintonSmith.
  • burgoyne
    burgoyne over 3 years
    Worked for me in VS 2019 with a .NET Core 5 project. The file path was slightly different: .vs\<MyProject>\config\applicationhost.config
  • havij
    havij over 3 years
    Worked in 2019 as well, without having to change the port.
  • Azoreo
    Azoreo over 3 years
    @QuintonSmith Thank you again. Deleting launch settings fixed it for me, whereas the other solutions did not. Whew!
  • Scuba Steve
    Scuba Steve over 3 years
    Lifesaver, worked in vs 2019, with Asp.Net Core 3.1 - the applicationhost.config file is one further directory deep in the .vs folder.
  • rory.ap
    rory.ap over 3 years
    @QuintonSmith Can you please make an official answer? I keep having to dig to find this when it happens every few months.
  • Quinton Smith
    Quinton Smith over 3 years
    @rory.ap - As requested - stackoverflow.com/a/65421182/4977243
  • Bigyan Devkota
    Bigyan Devkota over 3 years
    this worked for me, was an easy solution -- thanks
  • exrezzo
    exrezzo about 3 years
    Thank you @QuintonSmith it worked for me on .net core 3.1
  • viniciusalvess
    viniciusalvess about 3 years
    After trying a whole bunch of things. This solved my issue. Thank you @Jason J. Lee
  • WSK
    WSK about 3 years
    This is work around not a solution. In team development you can't change the debug port at your will.
  • sean717
    sean717 about 3 years
    @QuintonSmith... you, my man...deserve a medal. God bless you.
  • Alexander Zaldostanov
    Alexander Zaldostanov about 3 years
    Thanks buddy you helped me alot, I have been trying to fix this stupid error :)
  • vandsh
    vandsh almost 3 years
    Anyone using @QuintonSmith's approach of deleting the launchSettings.json it's located under the <project>/Properties folder. Took me a minute to find exactly where it was located but it did the trick!
  • Shahid Malik
    Shahid Malik almost 3 years
    Restarting my computer fix the problem.
  • John81
    John81 almost 3 years
    Only other thing that worked for my .NET Core 3 project besides rebooting the computer.
  • user2966445
    user2966445 almost 3 years
    Still didn't work for me in July, 2021 with VS 2019.
  • Poat
    Poat almost 3 years
    I did all the complicated answers (and some worked) but just restarting the computer did the trick :)
  • Faizan Mubasher
    Faizan Mubasher over 2 years
    None of this is working for me. VS2019 .NET Core 5.0
  • mgPePe
    mgPePe over 2 years
    Worked for me, given I didn't really do any changes before that
  • Reven
    Reven over 2 years
    Doesn't work for me.
  • Talon
    Talon over 2 years
    Nope, still get the same error
  • StarLord
    StarLord over 2 years
    @Talon Sometimes there will be more than one instance of the worker process in task manager. Make sure to end all of them.
  • user2211290
    user2211290 over 2 years
    It worked for me, someone please elaborate reason for this error
  • pradeepradyumna
    pradeepradyumna over 2 years
    This worked for me. Thanks ton!
  • Chris W
    Chris W over 2 years
    Try restarting the computer, as a last resort. If Quinton's workaround does not help.
  • Simon C
    Simon C over 2 years
    In my case it was OneDrive. Restarting that made it change ports and then I was able to run my application.
  • obaylis
    obaylis over 2 years
    Similarly for me, after trying all of the other steps (port, del .vs folder, reboots) I deleted launchSettings and back working. Strange thing is, just deleting .vs folder has worked when I encountered this previously. Not this time.
  • Arun
    Arun about 2 years
    It is helpful for me.
  • mfreedm52
    mfreedm52 almost 2 years
    agreed. tried everything before restart. but restart is the only thing that worked.