可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This is running on Windows Server 2008 and used to work several months ago. I am just now using this server again for some dev work with VS.
This is live web server used to serve up a few test sites as well.
This came up when running Visual Studio, then launching my projects for debugging.
Trying to launch any site through localhost:xxxx
when IISExpress has been launched (using actual port #'s in the config to access different sites):
This webpage is not available
ERR_CONNECTION_REFUSED
I have been at this for a few days already, as I have read others have had similar issues, tried most things I have read including changing the managedruntimeversion
from "v4.0" to "v4.0.30319" for .net 4.5 (I have never had to do this before) and disabling the logging module (all suggestions found here).
There are only two entries in my hosts
file that point to internal server IP addresses. No localhost
related IP's or references.
I have gone as far as re-installing IIS Express, and Visual Studio 2013. I also created a brand new WebApplication
site to try to resolve this (simple and no other complicated bindings).
When I spin up Fiddler, I see the following on the page:
[Fiddler] The socket connection to localhost failed.
ErrorCode: 10061.
No connection could be made because the target machine actively refused it 127.0.0.1:23162
I have removed all proxy settings from IE's LAN connection section, where before I was getting a red-x popup in VS indicating something like IISExpress could not launch.
This is not a matter of SSL vs non SSL.
I had TFS Server installed - uninstalled that in case there were some odd bindings that were interfering.
I tried deleting the IISExpress config/settings folder several times.
Current applicationhost.config contains:
<site name="WebApplication1" id="4">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\TFS-WorkRepository\Sandbox\WebApplication1\WebApplication1" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:23162:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
I wish there was a tag for really-stuck
.
Please suggest away, as I don't want to go as far as spinning up a new server.
-- UPDATE --
In the URL bar, when I enter the computer name or IP address :xxxx I get the ERR_CONNECTION_TIMED_OUT
rather than ERR_CONNECTION_REFUSED
.
回答1:
Try changing the port number in your project?
Project Properties → Web → Servers → Project Url:
Don't forget to click Create Virtual Directory
, or reply "Yes" to the prompt for creating virtual directory after you change your port number! (Thanks Connor)
Note: I'm a little reluctant to post this as an answer, as I have no idea what
the issue is or what caused it, but I had a similar issue, and changing the port number did the trick for me. I'm only posting this per the suggestion in the comments that this worked for someone else as well.
In my case, it seemed like something was conflicting with the specific port number I was using, so I changed to a different one, and my site popped right back up! I'm not sure what that means for the old port number, or if I'll ever be able to use it again. Maybe someone more knowledgeable than myself can chime in on this.
回答2:
Thanks for all the answers. I tried all of them but none of them worked for me. What did work was to delete the applicationhost.config from the .vs folder (found in the folder of your project/solution) and create a new virtual directory (Project Properties > Web > Create Virtual Directory). Hope this will help somebody else.
回答3:
This issue may be because in the recent past you have used IP address binding in your application configuration.
Steps to Solve the issue:
- Run below command in administrator accesses command terminal
netsh http show iplisten
If you see some thing like below then this solution may not help you.
IP addresses present in the IP listen to list:
0.0.0.0
If you see something different than 0.0.0.0 then try below steps to fix this.
- Run these command in succession in elevated command terminal
netsh http delete iplisten ipaddress=11.22.33.44 (where 11.22.33.44 is the actual IP that needs removing)
netsh http add iplisten ipaddress=0.0.0.0
iisreset
And now your issexpress is set to listen to any ping coming to localhost binding.
回答4:
I've just fixed this for my machine.
Maybe it will work for some. Maybe not for others, but here is what worked for me.
In IIS, I had to add bindings for https to the default website (or, I suppose, the website you are running the app under).
Now my localhost works when debugging from Visual Studio.
回答5:
In my case it was caused by starting IIS with no administrative rights. When I launched IIS as admin and started the site it worked fine
回答6:
Sam's solution worked for me, but I didn't want to run as admin as a permanent solution.
This is how I solved it in my case:
- Run CMD as admin
- Type "netsh http show urlacl" and find the reserved url with the relevant port
- Type "netsh http delete urlacl url=YourReservedUrlHere"
After that I could run my app without the need for admin rights. But it did messed with the ability to browse to my app from an external computer. Close enough for me for now.
回答7:
In my case, it was caused by an infinite loop/stack overflow.
回答8:
I solved this problem by starting Visual Studio with Run as administrator
. This is also required if you want to publish your project to the local IIS.
To set this permanently:-
- Right-click on the Visual Studio icon
- Select
Properties
- Click
Advanced
- Ensure
Run as administrator
is checked-on
- Click on
OK
all the way out.
- Start Visual Studio, load your project and start debugging
回答9:
My problem turned out to be a complete lack of understanding of the redirect uri in the auth process.
I downloaded some code that contained the following declaration:
string redirecturi = "http://localhost/googlesignin";
I was using vs2015 with a website template. There is no "googlesignin" webpage in my website, ever!
So why did this work at all for several days while developing my site?
Living proof that random bugs can cause code to work where it should have fail.
I changed googlesigin to GoogleDrive which is the name of my webpage and it all worked!
Boy am I stupid!
回答10:
Rebuild All worked for me. VS2013, IIS Express.
回答11:
I've solved by going to Project Proprieties -> Debug, after enable SSL and use the address in your browser
回答12:
In my case, my co-worker changed the solution name so that after I get latest version of the project, I run my web application with IIS EXPRESS, then I got the message ERR_CONNECTION_REFUSED
in my google chrome.
After I try all the solution that I find on the internet, finally I solved the problem with these steps :
- Close VS
Delete the .vs
folder in the project folder
Run As Administrator VS
Open Debug > [Your Application] Properties > Web
Change the port in Project URL and don't forget using https
because in my case, when I'm using http
it still did not work.
Click Create virtual directory
Run the application again using IIS EXPRESS.
And the web application ran successfully.
Hope these helps.
回答13:
Make sure you have a start page specified, as well. Right click on the .aspx page you want to use as your start page and choose "Set as start page"
回答14:
A simple work around(it worked for me) is use the IP address instead of localhost. This should be fine for your development tasks.
回答15:
I had the same problem. I tried these steps:
- Closed the Visual Studio 2017
- Removed the [solutionPath].vs\config\applicationhost.config
- Reopened the solution and clicked on [Create Virtual Directory]
- Tried to run => ERR_CONNECTION_REFUSED
- FAILED
Another try:
- Closed the Visual Studio 2017
- Removed the [solutionPath].vs\config\applicationhost.config
- Removed the .\Documents\IISExpress\config\applicationhost.config
- Reopened the solution and clicked on [Create Virtual Directory]
- Tried to run => ERR_CONNECTION_REFUSED
- FAILED
Another try:
- Closed the Visual Studio 2017
- Removed the [solutionPath].vs\config\applicationhost.config
- Removed the .\Documents\IISExpress\config\applicationhost.config
- Added 127.0.0.1 localhost to C:\Windows\System32\drivers\etc\hosts
- Reopened the solution and clicked on [Create Virtual Directory]
- Tried to run => ERR_CONNECTION_REFUSED
- FAILED
WHAT IT WORKED:
- Close the Visual Studio 2017
- Remove the [solutionPath].vs\config\applicationhost.config
- Start "Manage computer certificates" and
Locate certificate "localhost" in Personal-> Certificates
- Remove that certificate (do this on your own risk)
- Start Control Panel\All Control Panel Items\Programs and Features
- Locate "IIS 10.0 Express" (or your own IIS Express version)
- Click on "Repair"
- Reopen the solution and clicked on [Create Virtual Directory]
- Start the web-project.
- You will get this question:. Click "Yes"
- You will get this Question: . Click "Yes"
- Now it works.