Bizhan
Bizhan

Reputation: 17085

localhost, 127.0.0.1 and hosts file are not working on a specific port

I'm struggling with this problem for a while.

When I enter http://localhost:680/local in chrome's address bar, the web page is loaded and everything works as expected. But when I enter anything else including http://127.0.0.1:680/local I get an error: ERR_INVALID_HTTP_RESPONSE.

update: Today localhost stopped working as well.

enter image description here

My backend code isn't called and there is nothing received as I see in the DevTools:

enter image description here

This was working yesterday, and I don't know what has changed in my system.

If I change my port to 681 it works.

This is particularly important because I need to open the web page with URL prefix such as admin.mysite.net:680/local or user.mysite.net:680/local but adding these names to the hosts file doesn't do anything.

What I have tried:

ping:

When I ping 127.0.0.1 it tells me the IPv6: Reply from ::1: time<1ms and I've disabled IPv6 in registry but still it's showing ::1:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DisabledComponents = 0x20

I can ping all names in hosts they all resolve to 127.0.0.1 and I can see them all in ipconfig /displaydns

hosts:

I followed these instructions

I can edit C:\Windows\System32\drivers\etc\hosts but it doesn't make any difference. When I add or remove 127.0.0.1 localhost or other value I always get the same result. I created a new single line ANSI file with this content 127.0.0.1 aaa but aaa:680/local gives me the same error.

other:

I also tried ipconfig /flushdns and ipconfig /registerdns.

I executed netsh http add iplisten 127.0.0.1 and it added the IP address.

I tried incognito and I cleared chrome data.

I read that there was a bug with http-server so I tried npm uninstall http-server and npm install [email protected].

I have no proxy, no automatic configuration script in LAN settings, no firewall.

I'm out of ideas. What else can I try?

Upvotes: 0

Views: 5179

Answers (1)

Bizhan
Bizhan

Reputation: 17085

It could be related to resource sharing or as Mohith mentioned CROS (cross-origin resource sharing).

There was another service in background which was somehow blocking some resources (probably port 680) denying access to the backend. Stopping the service fixed the issue.

Upvotes: 1

Related Questions