Chrome returns ERR_FAILED for localhost - google-chrome

After some experiments with PWA I've encountered a strange issue with Google Chrome only. Every other browser works just fine.
When I load http://localhost the response is: "This site can’t be reached"
The error status is: "ERR_FAILED" (404)
Note:
"ping localhost" returns 127.0.0.1 (as it should be).
wget -qO - 'http://localhost' loads the correct content in terminal.
every other browser loads the correct content.
the setting in /etc/hosts leads to 127.0.0.1
if I access the content via IP (127.0.0.1) it loads just fine.
I have cleared the browsing cache
the PWA cache seems to be clean.
The offline box in the network tab is not checked.
If anyone has any ideas on what could cause the issue please share.
The only clue I have is that in the sources tab of the code inspector
there's the content of sw.js (my service worker) but there's nothing to do with it.

I came out that the issue was caused by a cookie called ServiceWorker.
After deleting it everything works fine.

Related

npm http-server downloads index.html instead of serving

I am using http-server with ssl certificate in order to test facebook instant games. However, while server is running localhost makes my browser download index.html file instead of actually serving it in a browser. The problem occures in chrome, but microsoft edge seems to be fine.
Use this URL http://127.0.0.1:8080/
instead of localhost:8080
I found out this problem only occurs in Chrome, edge seemed to work fine, so I decided to clear browsing data in the chrome settings and tried again and surprisingly it doesn't download index.html from localhost:8080 anymore! This method solved my issue.

ERR_CERT_AUTHORITY_INVALID error in Chrome while using Overrides

I'm trying to test some features in a production environment, and to achieve this I'm using Google Chrome overrides, that basically allows you to substitute a remote file with a local file.
It sometimes works, but after a couple of reloads it stops working and all the requests start failing, receiving this error in console:
Pay attention: I'm not talking of the full page warning that you see when you access an untrusted website, which has the same error code. I'm talking about the error in console which makes the website unusable.
I say this because I tried googling the error and I only see articles about the warning, that you can easily skip. This is a different subject.
What I tried so far, without success is:
Start chrome with the --ignore-certificate-errors flag
Enabling the allow-insecure-localhost flag in chrome://flags
But they didn't help. How can I tell Chrome to ignore the (inexistent) certificate?
Thank you
Edit
I add an image of my override configuration:
to-override is my local folder. Then I just clicked on a file in the source tab and selected save for override. I found the file in my local folder and I changed it. Changes are applied the first time, but on refresh everything stops working and all the requests fail.
My Chrome version is
71.0.3578.98 - stable - 64 bit

Chrome's Dev console doesn't post console.log("message")when page is loaded from localhost (XAMPP Apache Server)

I am running a simple jQuery code (developing a simple webpage), while following a YouTube jQuery & Ajax tutorial. Half way of the tutorial, I was running the index.html file directly from my PC folder on Google Chrome, and console.log("message") worked fine, posting the "message" on Chrome Dev console.
Getting into Ajax territory, the tut suggests running a local Apache Server with XAMPP.
Here is the problem, as the same code doesn't post anything on Chrome Dev console when the index.html is running from localhost throught XAMPP.
PrtSCR of the page loaded from localhost (left) and from file (right)
After a lot of searching I finally found what the problem was!
It was a browser cache issue! (I use Chrome)
So I disabled Chrome Dev cache, and it works fine!
Anonther solution that I found is Cache Killer extension for Chrome, that clears the browsers cache in every page refresh.

Deleting Chrome HSTS for facebook.com not working

I am currently doing some debugging on my website which involves calling the facebook API.
I've installed dnsmasq to work with my mac os X to redirect all request to facebook.com to 127.0.0.1
I have a echo server which will print out all the raw http request header on port 80 on my laptop.
Now comes my problem. When I access facebook.com, I realize chrome will automatically forward http:// to https:// for facebook.com
I googled and found the way of deleting this HSTS issue. I visit chrome://net-internals#hsts to see something like this:
HSTS chrome image
After entering "facebook.com" under "Delete domain", I can still query "facebook.com" in the input box below.
I tried clearing all user data on chrome, closing and reopening chrome and even using incognito mode.
Why is chrome still redirecting all request to facebook.com to https?
How can I disable this if chrome://net-internals#hsts is not
reliable?
The text next to the Delete domain box on chrome://net-internals/#hsts clearly states that preloaded entries cannot be deleted. This feature request was closed as WontFix in the Chrome bug tracker.
facebook.com and quite a few of its subdomains are included in Chrome's preload list.
You could use another domain name for your tests.
Just make api-calls to facebook-api-test.com, map that domain to localhost and proxy the calls.

Localhost not working in Chrome, 127.0.0.1 does work

I'm trying to run a local node server, but for whatever reason localhost:3000 does not work. The error page states This webpage is not available ERR_CONNECTION_CLOSED However, 127.0.0.1:3000 does work. I have tried making changes to my hosts file, but to no avail. Does anyone have any idea what's causing the problem?
Chrome version is 46.0.2490.80 m
Here are the steps I took to make this work correctly:
Edited my hosts file so 127.0.0.1 localhost. was present, and saved the file
Cleared my Chrome cache, specifically cookies and cached files
Cleared host cache in chrome://net-internals/#dns
Restarted chrome
Alternatively, this also works:
Navigate to chrome://net-internals/#hsts
Under "Delete domain", type localhost and delete
Unbeknownst to me, my project had an HSTS middleware that set an HSTS cookie
For me (I had HTTP and HTTPs dev server on same port)
Chrome Dev tools F12
Application tab
Clear storage sub-tab
"Clear site data" button
I ran into a similar issue on my MacBook but none of the existing answers worked. I even tried the nuclear option and did a factory reset on my computer.
The issue turned out to be coming from the AirPlay receiver listening on Ports 5000 and 7000, which was creating the 403 error when I tried to serve something at localhost:5000.
The solution, as detailed here, was to uncheck AirPlay Receiver in System Preferences > Sharing
I solved my problem by:
opening the developer console F12
Going to network tab
Check Disable Cache
Browse locahost
What you can do is go to Chrome setting > Privacy and Settings > See all the cookies and site data, search for localhost and delete it. Then refresh your site it will be working.
Regards
if you're using a proxy there's a checkbox to bypass it for local addresses.
follow these steps.
open chrome
go to setting
Privacy and security
Clear browsing data
check cookies and other site data
click clear data.
I had same issue and I cleared cookies and cache and it worked
Go to Setting/clearBrowserData and just check all of history, cookies and cached files.
For me, Browse in Private (Ctrl + Shift + N) was enough.
Finally I have solved this problem
For those who have tried the clearing the cache from the browser and still facing the same issue follow these steps
search for live server(ctrl+shift+x) you will find a settings icon. click on Extension
settings
you can find Live server>Settings:Chrome Debugging Attachment click on edit in Settings.json
just add this (if there are multiple lines make sure to add comma[,])
"liveServer.settings.port": 0
Doing This It will randomly pick an opened port each time.