Can't access 127.0.0.1 - windows

I can't figure out when this started to happen, but the result is - 127.0.0.1 is not working on any port from anywhere (for example, browser says Unable to connect). Here are the results of my research:
localhost, COMPUTER_NAME and actual IP address all work fine
there is nothing special in my hosts file
ping to 127.0.0.1 and tracert do work fine
all the programs that have 127.0.0.1 hardcoded are not working (this point makes me disappointed the most, because I can't do anything in this case )
What else can I do to identify the source of problem and fix it?
UPDATE: as soon as Redis does work on 127.0.0.1 and both IIS and AzureStorageEmulator don't work I assume this is HTTP only issue.

Just one command did the work
netsh http add iplisten 127.0.0.1

If it's a DNS problem, you could try:
ipconfig /flushdns
ipconfig /registerdns
If this doesn't fix it, you could try editing the hosts file located here:
C:\Windows\System32\drivers\etc\hosts
And ensure that this line (and no other line referencing localhost) is in there:
127.0.0.1 localhost

In windows first check under services if world wide web publishing services is running. If not start it.
If you cannot find it switch on IIS features of windows: In 7,8,10
it is under control panel , "turn windows features on or off".
Internet Information Services
World Wide web services and
Internet information Services Hostable Core are required.
Not sure if there is another way to get it going on windows, but this worked for me for all browsers.
You might need to add localhost or http:/127.0.0.1 to the trusted websites also under IE settings.

I had a similar issue. Check your listen port.
A mistake I made ealier was
app.listen(() => console.log(APP_NAME} is listening on port ${PORT}`))
Make sure you include the port as shown below
app.listen(PORT, () =>{
console.log(`${APP_NAME} is listening on port ${PORT}`)
})

This answer may seem overly obvious, but in most cases it is sufficient to simply remove the "localhost" entry in the "Host Name" field:

In the end for us, it was IE11 that was blocking for 127.0.0.1 - after adding it to the exceptions list, it loaded the page.

Related

/etc/hosts doesn't work for localhost only

What I need:
Localhost points to the IP of my other PC on the local network.
What I tried:
I added "IP localhost" to the /etc/hosts file.
Command ran: "ipconfig /flushdns"
Browser: Edge/Chrome/Internet Explorer
This doesn't work, but if I name it anything else than "localhost" it does actually work.
I know it is something about the DNS, but I read online that the hosts file should overwrite it.
Partly solution
Google OAuth only accepts localhost or example.com as redirect URL. Not being able to use localhost on a different PC for testing, I solved this by using example.com on both the local PC and the second PC. I added the following to the hosts file:
Local PC: 127.0.0.1 example.com
Second PC: IP_OF_LOCALPC example.com
You can then use URL example.com:PORT. This isn't supported by Microsoft OAuth though (I guess I will only use Google Login for developing). Any ideas on how to solve this for Microsoft OAuth are welcome :)
Are you using Chrome?
Chrome has it's own DNS, if you use another browser then it's likely it will work as you expect.
Edit: Confirmed that this is still possible in Safari today on a Mac (26/12/2021). However, browsers appear to be clamping down on this - and are making an effort to make sure that localhost and *.localhost will only ever point to your local machine.

/etc/hosts file not redirecting to local application on mac

I've set up a redirect in the hosts file on my machine that basically points an auth domain to my local project in IIS (when run in Visual Studio for Mac) - however when I type the domain name into Chrome (for example), I get a message saying this site cannot be reached.
The local URL I want this to point to is: http://localhost:44380/ - the live URL I can't reveal for security but lets say for the sake of this example that it's: auth.site.com (the actual URL I'm using is valid and it does load in Chrome)
Here's my hosts file from terminal as it's currently set up:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 auth.site.com
I'm very familiar with windows and how the hosts file works, so from what I know there this would work in windows (I think anyways), is there something I'm missing here because obviously something isn't right?
I would first check where the problem is exactly. I think of the following possible issues:
Hosts file not properly working: Try running ping auth.site.com in a terminal. If you see responses from 127.0.0.1 this should work.
Is access to the port possible, open http://localhost:44380 in your browser. If you see your page, this should work.
Combine the two parts: open http://auth.site.com:44380 in your browser. If this does not work, maybe there are security features from the original page you visited before preventing access (like forcing SSL or a pinned certificate).
Try another browser or curl auth.site.com:44380 in a terminal.
If you are not happy with the given ports, you can do a port forwarding. Changing ports is not possible in the hosts file, because the hosts file is only for domain name lookup and this has nothing to do with the ports.
The listening address on the local instance would be http://auth.site.com:44380/

Can't browse local domains without a network connection

I have a few different PHP sites running on local domains (i.e. domains set to 127.0.0.1 in /etc/hosts) so I can work on them without any network delay.
I'd like to be able to work on these sites when I have no connection at all (e.g. on the bus or in the park) but my browser (Firefox on LinuxMint) can't load the local pages when there's no network connection (it doesn't have to have Internet access, but it must have a working network connection). Note that it can load a site via local IP addresses or "localhost", but not using any other local domain name.
I'd like to create some kind of local network that makes the Network Manager show a valid connection even when there is no LAN adapter present. Or alternatively a way to make Firefox work with the local domains without needing the network would be just as good.
Reproduce this problem as follows:
- Run a local web-server such as micro_httpd and serve a test site
- Set up some other names for 127.0.0.1 in addition to localhost in your /etc/hosts file such as foo.bar
- Test that your site works from localhost and from foo.bar
- Unplug your network cable
- Test again, only localhost works, not foo.bar
- Test with wget, both work fine
I have the same issue. Either of these work for me, in Firefox go to about:config and click I'll be careful, I promise!, search for network.dns then either:
Set network.dns.disableIPv6 to false
or
Add your local domain names to network.dns.localDomains
I think the latter is probably the better of the two options, but either works for me.
Adding a little to Lee Kowalkowski answer:
I have modified below at admin:config in my firefox developer edition 61.0b3 (64-bit)
network.dns.localDomains added localhost as I bind my local sites with localhost
I haven't needed this functionality for a couple years and noticed now as of Firefox 60 that there is no problem any more.
This old Bugzilla thread mentions the issue and says it was resolved by adding the about:config key network.dns.offline-localhost, perhaps that's set to true by default now which is why it works?

Can't access my index.html (via Apache) from other computer (LAN nor Internet)? Please help

lets make it simple to answer.
I installed Apache 2.2. Now when I do 127.0.0.1 in Firefox, I get the "It works" page. When I do 10.0.1.10 (my servers internal IP) on another PC on the SAME network, I won't get anything :-(. I forwarded port 80 on my router and made sure Firewall doesn't block Apache. If I type my external IP:80 I still can't get into my "index.html". My settings (more less default)
Network Domain: localhost
Server Name: localhost
I also got a FTP via FileZilla running on that PC. It works perfectly, even over Internet. I have also set up a DynDns hostname. If I do ftp://mydyndns.hostname.com I get to my ftp server.
What am I missing? Some more Windows setup?
Thanks a lot in advance!
I installed Linux on my computer and found all servers run better on it :) Thanks everyone...

localhost host not working on XAMPP

I am facing same problem to the thread. I've gone through all the suggestions provided in the solution. I've searched all possible solution but nothing gonna workout.
"http://stackoverflow.com/questions/817745/localhost-not-working-on-xampp-both-service-apache-mysql-are-fine"
I've ensured :
1. Xampp is successfully started (in log) but it is not receiving any request(checked access.log).
also ensured that it is running on port 80 in config file.
confirmed status of application using netstat
C:\Documents and Settings\user>netstat -aon | grep 80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3524
Checked host file in /windows/system32/drivers/etc/hosts and has only one entry
127.0.0.1 localhost
skype teamviewer or other application are closed and configured not to use port 80.
ensured that windows firewall allows http process to use port 80.
pinged localhost, 127.0.0.1 and my ip (192.168.1.2). localhost resolves to 127.0.0.1
tried different urls http:// localhost http:// localhost:80 http:// 127.0.0.1 http:// laptop-name but nothing works. browser just waits for response (spaces after http to allow links in this post)
ensured that there is no loop in index.php(it is untouched) and also has index.html. also tried diffent paths
nothing gonnna work out. I am irritated and I dont want to format my machine. please help....
when this happens to me it is usually Skype taking over the default localhost address
Check on command prompt
netstat -a -b
And close any other application like skype etc using 80 port.
Try stopping IIS. It worked for me.
Select Start, then type IIS in the search box
select Internet Information Services Manager
In the manager on the right under "Manage server"select "stop"
I was having an issue with Last.fm that is very similar to yours, and I found that it was a software conflict.
The Last FM scrobbler application would not finish installing on my new build because it couldn't login or authenticate my username. I tried the regular scrobbler application and then tried the beta desktop program on Windows 7 64 bit. I suspected Skype or TeamViewer, but even after stopping or exiting those programs, neither versions of the installation would log in to the services.
The beta desktop application actually authenticated on 127.0.0.1 (random port) through my internet browser, but my browser would time out trying to send data over the port.
I checked and edited my HOSTS file in Windows, but that didn't fix the issue either.
Pinging 127.0.0.1 worked, but pinging any variation of the port would time out.
Finally, I decided to uninstall the Windows 7 Firewall Control program made by Sphinx Software. Mind you, I had set the firewall to be disabled at start up (clean start-up - all startup programs disabled through MSConfig).
I made sure that the firewall program was not running at all in my services. However, after uninstalling the software, even without restarting my computer, 127.0.0.1 opened up on all ports and my Last.fm scrobbler finally connected and finished installation.
So, it may be a hidden setting that can only be undone by uninstalling programs (even programs that aren't running).
For me localhost was not the correct address.
Type into cmd "hostname" and use that as the url.
CMD -> hostname
If that doesn't work try just the ip address of the server (or computer)
I stored my website folder in xamp/htdocs (windows machine). Then I started apache on the XAMP control panel. My pages rendered successfully when I called http://localhost/mysite/index.html.
I hope this is helpful.

Resources