Introduction
This problem appeared out of the blue in Visual Studio 2005 on my work laptop. Google didn’t help with a solution, so I thought a brief blog post was in order.
The Issue
Trying to launch any ASP.Net application on my local machine, either in debug mode or starting without debugging, started the Cassini ASP.Net Webserver just fine, but the browser just threw up an “unable to connect” error. Google seemed to suggest it might be a corrupt webserver exe, but it seemed to be running fine so I ignored that option. I tried manually specifying a port in the project settings, and even using telnet to try access the port on localhost from the command prompt, but even though the webserver was running, nobody was listening!
The Fix
After clutching at random straws for a while I did a “ping localhost” from the command prompt and noticed it was returning replies from ::1 (the IPv6 “loopback” address). I popped open my hosts file (c:\windows\system32\drivers\etc\hosts) and noticed that localhost was mapped to ::1, but not to 127.0.0.1. I have no need for IPv6 on my machine so I commented out that line and added:
127.0.0.1 localhost
Fired up Visual Studio, pressed F5 and voila – all fixed! I’m not sure why this was suddenly a problem, it just appears that Cassini just doesn’t like being accessed via IPv6, but this seems to be the solution if this issues bites you 🙂
Interesting; I’ll watch out for that one. BTW, was this 633968 on SO?
@Marc That wasn’t me, but it’s the same problem I think.
Just curious. Are you running Windows Defender? A few people started reporting this earlier in the week. Looks like it may be related to a Defender signature update which was quickly fixed. You should find everything works again if you put things back the way they were. No easy way for me to test this though as I run Forefront client security which disables Defender. Mike
@Mike Yep, and it did occur after a nightly update/reboot cycle so that could well be the culprit. Thanks for the comment.
Thanks. Got the same problem from today mornig. That did the trick.
Not sure how or why this became a problem for me, but you nailed it. I’m changing my hosts now. Thanks!
Thanks for the fix. Same problem was happening to me. Still, I have no idea was what causing this change in the host file.
unable to connect to asp.net webswerver getting this prolem with vs2008 plz tellmehow to cinfigure iis
I am having a problem with running an ASP.Net project on my laptop that is running XP professional (SP2) and IIS 5.1. When I start a new ASP.NET project in Visual Studio I get the error message:
”Unable to create Web Project ‘WebApplication1’. Could not find a web server at ‘localhost’ on port 80. Please check to make sure that the web server name is valid and your proxy settings are set correctly. If you are sure that everything is correct, the web server may be temporarily out of service”.
If I try accessing an existing ASP.Net project I copied from another Machine I get the error:
“Unable to open Web project . Unable to validate that the file path ‘C:\Inetpub\wwwroot\’ matches the URL path ‘http://localhost/’. A connection with the server could not be established.
When I try to load up the IIS default page in Internet Explorer (using ‘http://localhost/’ as the address) it tells me ‘WWW disabled’ even though IIS appears to be running fine. I can however load the ASP.NET project start page by using 127.0.0.1 as the address rather than localhost. It looks like localhost is not mapped to 127.0.0.1 but when I ping both in the command window I get replies indicating that they are mapped?
It’s not the same problem, but I’d suggest you take a look at your proxy setting and make sure that bypass proxy for local addresses is set (if you use a proxy) and possibly add 127.0.0.1/localhost explicitly to the bypass list.
I am Also Facing Problem I Have Windows Vista installed with iis 7 , IE 8
i was unable to run the web application ( Visual Studio 2008 ) C#.net Application
i am geeting unable to establish connection with local host
Any one please help me to solve this
Your clear explanation of the issue and fix saved me hours and hours of time. Thanks a million.
I had a similar problem with IE8 and found this worked for me:
http://stackoverflow.com/questions/663144/why-cant-i-debug-from-visual-studio-2005-after-installing-ie8
IE 8 has a feature called Loosely-Coupled Internet Explorer (LCIE) which results in IE running across multiple processes.
http://www.microsoft.com/windows/internet-explorer/beta/readiness/developers-existing.aspx#lcie
Older versions of the Visual Studio Debugger get confused by this and cannot figure out how to attach to the correct process. You can work around this by disabling the process growth feature of LCIE. Here’s how:
Open RegEdit
Browse to HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
Add a dword under this key called TabProcGrowth
Set TabProcGrowth to 0
Since you are running on Windows Server 2003, this is all you should need to do. If you run into the same problem on Vista or newer, you will also need to turn off protected mode.
First of all, I’m a Newbie to .NET. Secondly, The problem I’m facing is I am not being able to change the ::1 to comment and update 127.0.0.1. Must tell you that it is my personal laptop and I am the administrator. I’m really confused what to do. I also installed the Cassini webserver but don’t know how to use it
I had the same issue and fixed.
Thanks
Khalid
Thanks man!
It worked as well!
also… sometimes if you have things set up to use HTTPS / SSL (think [RequireHttps] in ASP MVC), and attempt to run the website locally without HTTPS, you will likely experience this issue as well.
I am using Windows XP Sevice Pack 3 with VS8
I am also facing the same problem in localhost.
When i run my website “localhost:1774/WebSite/Default.aspx” the page cannot be displayed error occurs .
I have also checked “C:\WINDOWS\system32\drivers\etc\hosts” file it is correct i-e 127.0.0.0 localhost
still i am facing the problem kindly help me out.