ASP.NET 5 MVC: unable to connect to web server 'IIS Express'
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:
- Delete
YourSolutionFolder\\.vs\config\applicationhost.config
file (note: .vs is a hidden folder) - 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
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:
- Delete .vs folder (it is a hidden folder).
- 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
-
- 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
- closing VS,
- deleting launchSettings.json
- 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.
Related videos on Youtube
Sarek
Updated on July 08, 2022Comments
-
Sarek almost 2 years
What I'm doing:
- Opening Visual Studio Community 2015
- File -> New -> Project
- Under Visual C#: Web -> ASP.NET Web Application
- Web Application
- And press f5 for the popup error "unable to connect to web server 'IIS Express'."
Deleting
applicationhost.config
, located inDocuments\IISExpress\config
, doesn't change the error message. (There's also anIISExpress
folder inprogram files
andprogram 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 about 8 yearsDoes this help? stackoverflow.com/questions/15873126/…. Or changing the port? stackoverflow.com/questions/23502327/…
-
Hazem Torab about 8 yearstry when you open visual studio right click and open as administrator..
-
Sarek about 8 yearsI'm trying all suggestions people give me even if I have tried before.
-
Sebastian 506563 about 8 yearscan you open new project an check if this is working? Restart PC? Move project to other directory
-
Sarek about 8 yearsThank you but that also didn't work.
-
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 about 8 yearsI 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 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 about 6 yearsASP.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 over 5 yearsThis 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 almost 5 yearsthis article solved my issue -> overengineer.net/…
-
Mahmut EFE over 3 yearsClose Visual studio. Try to delete Bin, Obj and vs folder. After that problem should resolve, It worked for me.
-
VSO about 3 yearsLast 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 about 8 yearsMan, 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 about 8 yearsOmg, 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 over 7 yearsI 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 over 7 yearsJust installed Update 3, started getting this error after adding a new class to a Core project. This solution worked for me.
-
EKanadily over 7 yearsIt worked but only when i used port 60000 . port 6000 returned error : unsafe port.
-
Shiham almost 7 yearsMay be explain you answer a bit. Just killing the process might not be the answer here. And what after?
-
mlienau almost 7 yearsThis worked for me in VS2017, without having to change the port.
-
wisetap.com almost 7 yearsAfter doing this for me was needed run Visual Studio as Administrator, and worked, thanks!
-
Bart Mensfort about 6 yearsEspecially the RUN AS ADMINISTRATOR is important for me. (although I have Asp.net Core 2.0 VS2017.
-
Lex Li about 6 yearsWhen
launchSettings.json
is automatically generated or updated by VS, theapplicationUrl
should have/
in the end. More info can be found in blog.lextudio.com/… -
Lex Li about 6 yearsOnly administrator permissions allow the application to bind to a port number smaller than 1024. That's why 6767 works for you.
-
FindOutIslamNow almost 6 yearsDeleted the whole
.vs
folder and worked for me, just that -
Tonmoy almost 6 yearsRestarting 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 over 5 yearsChanging the port number is annoying af when you have saved testing requests
-
MercifulGiraffe over 5 yearsThis worked for me, but also only after I restarted VS in Administrator mode.
-
Muhammad Musavi over 5 yearsNon 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 checkShow process for all users
and selectw3wp.exe
(sometimes need to refresh the website to findw3wp.exe
) and then hit theAttach
button. -
Prolog about 5 yearsThis 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 about 5 yearsFor me it was
.vs\config\<MyProject>\config\applicationhost.config
-
Meir about 5 yearsAfter three days of plucking hair, this solution helped me. Thank you
-
GMc almost 5 yearsThis 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 almost 5 yearswhere do you see
web site
that you need to right click on? -
Madhusudhan V Indian almost 5 yearsI 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 almost 5 yearsWorked for me, but had to do it twice!
-
Robert Bratton almost 5 yearsI was able to do this by shutting down only Visual Studio, deleting the .vs folder, stating Visual Studio again.
-
Daniaal almost 5 yearsYeah 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 almost 5 yearsIt 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 almost 5 yearsAh 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 almost 5 yearsVS 2019 - .vs\config\<MyProject>\config\applicationhost.config worked for me, too.
-
Ulysses Alves almost 5 yearsI'm running VS as Admin but I still get the same problem.
-
johnbt over 4 yearsGot this after a bluescreen. Had to delete .vs folder and restart the computer. Restarting visual studio was not enough.
-
Daniaal over 4 yearsGlad 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 over 4 years@SarahLissachell Amazed me too! Took me hours to figure it out so i am glad it helped :)
-
Matt Searles about 4 yearsChanging the port number did the job for me
-
WeisserHund about 4 yearsThis was the solution for me, Thanks
-
MedievalCoder about 4 yearsAlthough 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 about 4 yearsDidn't work in Visual Studio 2019 - it just used the same port each time.
-
dxk3355 about 4 yearsUsing 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 about 4 years@EJoshuaS-ReinstateMonica I believe this has changed a lot. Take a look at how your
Startup
class is configured and whatappsettings.json
files you have. There is alsoProperties\launchSettings.json
to launch different profiles locally. docs.microsoft.com/en-us/aspnet/core/fundamentals/… dejanstojanovic.net/aspnet/2018/december/… -
Quinton Smith about 4 yearsFor 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-generatedlaunchSettings.json
. It was not apparent that the file was corrupt or incorrect or even when it changed to cause failure. -
samneric about 4 yearsMy steps were compressed to: 1) Clean Solution. 2) Exit Visual Studio. 3) delete .vs folder
-
Daniaal about 4 years@samneric Thanks for that, i'll add you solution to the answer :)
-
samneric about 4 yearsactually, 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 almost 4 yearsVS 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 almost 4 yearsThe solution worked. Thanks :) How about DELETE the .git folder as well?
-
Patrick Borkowicz almost 4 yearsSeems 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 almost 4 yearsAlso .vs folder is a hidden to un-hide it first.
-
Anand Murali almost 4 yearsThank you @QuintonSmith. Your solution worked for me in .NET Core 3.1 as well.
-
Alex Pandrea over 3 yearsto highlight the change:
http
instead ofhttps
-
Alex Pandrea over 3 yearsI 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 over 3 yearsYou are not a start, but a superstar! Thanks it worked
-
Sanket Sonavane over 3 yearsThanks Quinton you saved the day
-
Sk Shahnawaz-ul Haque over 3 yearsThanks @QuintonSmith, your solution is working in Visual Studio 2019 Preview for ASP.NET Core 5 (.NET 5 RC2 SDK) as well.
-
isierra over 3 yearsFirst 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 over 3 yearskeep in mind with will delete all the previous setting like swagger or docker so just make a copy of the old one @QuintonSmith.
-
burgoyne over 3 yearsWorked for me in VS 2019 with a .NET Core 5 project. The file path was slightly different:
.vs\<MyProject>\config\applicationhost.config
-
havij over 3 yearsWorked in 2019 as well, without having to change the port.
-
Azoreo over 3 years@QuintonSmith Thank you again. Deleting launch settings fixed it for me, whereas the other solutions did not. Whew!
-
Scuba Steve over 3 yearsLifesaver, 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 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 over 3 years@rory.ap - As requested - stackoverflow.com/a/65421182/4977243
-
Bigyan Devkota over 3 yearsthis worked for me, was an easy solution -- thanks
-
exrezzo about 3 yearsThank you @QuintonSmith it worked for me on .net core 3.1
-
viniciusalvess about 3 yearsAfter trying a whole bunch of things. This solved my issue. Thank you @Jason J. Lee
-
WSK about 3 yearsThis is work around not a solution. In team development you can't change the debug port at your will.
-
sean717 about 3 years@QuintonSmith... you, my man...deserve a medal. God bless you.
-
Alexander Zaldostanov about 3 yearsThanks buddy you helped me alot, I have been trying to fix this stupid error :)
-
vandsh almost 3 yearsAnyone 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 almost 3 yearsRestarting my computer fix the problem.
-
John81 almost 3 yearsOnly other thing that worked for my .NET Core 3 project besides rebooting the computer.
-
user2966445 almost 3 yearsStill didn't work for me in July, 2021 with VS 2019.
-
Poat almost 3 yearsI did all the complicated answers (and some worked) but just restarting the computer did the trick :)
-
Faizan Mubasher over 2 yearsNone of this is working for me. VS2019 .NET Core 5.0
-
mgPePe over 2 yearsWorked for me, given I didn't really do any changes before that
-
Reven over 2 yearsDoesn't work for me.
-
Talon over 2 yearsNope, still get the same error
-
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 over 2 yearsIt worked for me, someone please elaborate reason for this error
-
pradeepradyumna over 2 yearsThis worked for me. Thanks ton!
-
Chris W over 2 yearsTry restarting the computer, as a last resort. If Quinton's workaround does not help.
-
Simon C over 2 yearsIn my case it was OneDrive. Restarting that made it change ports and then I was able to run my application.
-
obaylis over 2 yearsSimilarly 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 about 2 yearsIt is helpful for me.
-
mfreedm52 almost 2 yearsagreed. tried everything before restart. but restart is the only thing that worked.