This problem has a very simple (almost silly) fix, but it took me 2 hours to discover today, and none of my searches gave the answer, so I am posting this along with the answer to help others.
I have a website set up in IIS to run locally, which has worked in the past.
The URL is like: http://localhost/mywebsite
But today when I tried to open the site, it did not work in any of my browsers (IE, Chrome, and Firefox). Even the main IIS Welcome page at http://localhost was not working.
Internet Explorer showed: "Can't reach this page / Make sure the web address http://localhost is correct". Under "More information", it showed "There was a temporary DNS error. Try refreshing the page. Error Code: INET_E_RESOURCE_NOT_FOUND"
Firefox showed: "Unable to connect / Firefox can't establish a connection to the server at localhost."
Chrome showed: "This site can't be reached / localhost refused to connect / ERR_CONNECTION_REFUSED"
Neither restarting the server in IIS, nor calling iisreset from a command prompt fixed it.
I compared my "hosts" file to another computer which was not having the problem. Both had the same entry for "127.0.0.1 localhost".
I checked the Services panel and verified that "World Wide Web Publishing Services" was running.
I ran "netstat -a". It showed nothing listening on port 80, but I didn't know what was causing that.
Based on suggestions I found while searching for a solution, I tried the following, none of which fixed the problem:
I turned off User Account Control.
In IIS, I updated the Site Bindings for "Default Web Site" to change the port number from 80 to a different value, 8085. The site did not load with the new port number either.
In case something in IIS had gotten corrupted or messed up, I used "Turn Windows features on or off" to turn off all the features for Internet Information Services. Then after rebooting, I turned them all on again and rebooted again.
I still had the same problem.
What else could be causing IIS and my local website not to work?