How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress – Error 502 (Cannot debug from Visual Studio)?

Try changing the port number in your project?

Project Properties → Web → Servers → Project Url:

enter image description here

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.

Leave a Comment