I have copied my solution file from another system and tried to run it on my machine: For this, I have gone to the project folder and deleted the previous solution file and copied the new one.
Now, it started giving me error. connection refused etc. So, I got one solution from here: How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)?
According to it, I changed the port number from 1049 to 1052. It loaded and one of the pages gets loaded. But when I entered the desired login credentials then it redirected to the older port again, like this:
http://localhost:1049/Home/SearchFlight
and the error is:
This site can’t be reached
localhost refused to connect.
Search Google for localhost 1049 Home Search Flight
ERR_CONNECTION_REFUSED
Now, I don't know what to do from here. I have changed the port number to 1052 but still its pointing to 1049. What should i do now?
Open cmd as administrator and run this command:
ipaddress is your private ip.
This worked for me.
I recently ran into this exact problem and tried most of the suggestions but it turns out my problem was something different.
Our application has a section that redirects you to HTTPS if you are on HTTP (yes, I know there are better ways but this is legacy). In addition, there is special handling of localhost when you are in dev mode which redirected you back to HTTP, though I don't know why.
I have a new requirement that requires testing in HTTPS.
On a normal web page, changing http:// to https:// and calling Redirect would work fine but in IISExpress you are using custom ports. So for example, if you are on https://localhost:44300 you can't just switch to http://localhost:44300 b/c that port only serves https, not http.
So, if you are having this problem and you've cleared the config files and it didn't help, check your code for redirects. you might have something using a hardcoded or partially hardcoded url or a url from a config file that you haven't updated to https.
Update: I also suggest clearing all .suo and .user files and someone else suggested clearing the obj/ folder. I suggest doing this with VS closed and then restarting. I had a lot of trouble with values for ports being cached when i tried to setup https:// and change ports. I also suggest trying this suggestion to check that the SSL port is within the correct range, though I don't know if that is still a requirement https://stackoverflow.com/a/24957146
I had the same problem. Deleting
.vs
folder (including all contents, folder might be hidden) worked for me.Usually on local machine we are getting errors like
This site can't be reached localhost refused to connect
because we have self signed certificate configuration broken for local IIS Express. Sometimes it happens when you change URLs inlaunchSettings.json
or never configured self signed certificates on this machine at all.To fix self-signed certificate on the local machine you need to:
Run these commands in
cmd
:cd C:\Program Files (x86)\IIS Express
IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:12345/ -UseSelfSigned
Make sure you run VS2017
As Administrator
and check if the issue addressedNote:
https://localhost:12345/
is what is in yourlaunchSettings.json
forHTTPS
I've tried everything but nothing worked, but this did. If you can debug on local IIS instead of Express, change the configurations as shown in the image below. Do not forget to click on "Create virtual directory"
This solution worked for me:
Go to your project folder and open
.vs
folder (keep your check hidden item-box checked as this folder may be hidden sometimes)in
.vs
folder - open configsee that
applicationhost
config file there? Delete that thing.(Do not worry it will regenerate automatically once you recompile the project.)