Reputation: 5598
Google Chrome is ignoring the settings in C:/Windows/System32/drivers/etc/hosts
file. Both IE11 and Firefox are installed on the same machine and work as expected.
I've tried all the solutions I could find online including:
chrome://net-internals/#dns
and click the Clear Hosts Cache button.http://
to the front of the web address.cmd.exe
and run ipconfig /flushdns
I'm at a loss... Is there anything I missed that I can try or check?
Upvotes: 80
Views: 98065
Reputation: 1
I've just added Virtual Hosts extension for Google Chrome, and configure it. That's it. (But you need to find the right one).
Upvotes: 0
Reputation: 500
You could bypass the host file issue altogether by running this command:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --guest --host-resolver-rules="MAP example.com 1.2.3.4" --ignore-certificate-errors "example.com"
Note: all other instances of Chrome must be stopped for this to work.
It opens a new Chrome instance, with a domain mapped to an IP, and navigates to that domain.
Upvotes: 0
Reputation: 337
Chrome recognizes the URLs mapped to IP ::1
and you must also specify the subdomain example www
.
Example: You need to insert the following line for blocking www.youtube.com:
::1 www.youtube.com
Upvotes: 1
Reputation: 21
The answer from @tim-schmidt is the only thing that worked for me. The site was working on both wsl and windows command-line (curl) but not in chrome.
Adding both IPv4 and IPv6 domains in hosts
file solved it.
::1 www.mysite.local
127.0.0.1 www.mysite.local
Current setup: Windows 11 + WSL2 Ubuntu + Google Chrome
What didn't work for me:
Upvotes: 2
Reputation: 4786
For me
chrome://net-internals/#sockets
Flush socket pools work wonder, credit: https://superuser.com/a/611712
Upvotes: 1
Reputation: 181
Okay I faced the same problem but then I found the solution. Try this: Go to history (Ctrl+H) -> In the left pane click on Clear browsing data In the new window that opens go to Advanced tab Set Time Range to All Time -> check Cached Images and Files -> click on Clear data Restart your computer, It should start redirecting addresses mentioned in Hosts file (C:\Windows\System32\drivers\etc\hosts)
Note: This Solution is only for Google Chrome
Upvotes: 10
Reputation: 3509
Seems that Chrome doesn't likes the following extensions for that kind of stuff:
.dev
.localhost
.test
.example
.app
Use .local and the problem seems to disappear.
Upvotes: 43
Reputation: 2015
Running Chrome 105 on Windows 11, nothing seemed to work until I added ::1
(i.e. ipv6) in addition to 127.0.0.1
. For example:
127.0.0.1 local.foo.com
::1 local.foo.com
Upvotes: 15
Reputation: 5131
😊 simple answer 😊
there are 3 workarounds about this:
1- deleting Visited Links
binary file (beauty👍)
2- using .local
or .app
instead of your desired TLD (standard & preferred by chrome docs but i don't like it)
3- restarting your computer (ugly👎)
deleting Visited Links
binary:
C:\Users\[USERNAME]\AppData\Local\Google\Chrome\User Data\Default\Visited Links
binaryyou can define a function in your shell profile to perform this fast and just by a command whenever you face this issue: e.g:
function respectHosts () {
$path = $HOME + "\AppData\Local\Google\Chrome\User Data\Default\Visited Links";
Remove-Item $path;
}
it is suggested that first time after deleting Visited Links
binary file, also delete your history cause if you use a url from history, actually you are using the cached dns of that url too:
Upvotes: 1
Reputation: 1
Had a similar issue working from a windows based server that had proxy settings. In the proxy advanced settings there are 2 options that can help. Ignore proxy setting for local hosts which is a check box; as well as a list of addresses set off my semi-colons where you can except out certain IP destinations. This fixed my issue.
Upvotes: 0
Reputation: 361
If anyone stumbles on this problem in 2021, for me the fix was to disable Use secure DNS
option from chrome settings. After disabling that, all the options in the hosts file started working.
The option is located under Privacy and Security > Use secure DNS
Link to get there faster:
chrome://settings/security
Upvotes: 36
Reputation: 6187
This has been identified as a "bug" in Chrome, but it appears to be absolutely intentional behavior. Google Chrome does not honor /etc/hosts
when connected to the Internet. It always does a DNS lookup to determine IP addresses.
While my references below mostly relate to my expereinces with this on Linux, it is not confined to Linux.
https://groups.google.com/a/chromium.org/forum/#!topic/net-dev/iKXqyc40tW0
https://superuser.com/a/887199/75128
https://bugs.chromium.org/p/chromium/issues/detail?id=117655
Upvotes: 17
Reputation: 3821
I just encountered this tonight and none of these options worked. I discovered that Chrome now hides "www" (https://www.howtogeek.com/435728/chrome-now-hides-www-and-https-in-addresses.-do-you-care/). Chrome was using my hosts file, but I had to add "www." to my hostname in my hosts
file since that's what the browser is actually requesting, even if it doesn't show it.
Upvotes: 6
Reputation: 23
A little late, but after hours i find a solution. It seems that Google Chrome sometimes has problems on recognize the name of the hosts defined en /etc/hosts.
I'm using linux and i'm behind a proxy.
Try adding at the end of the name server: .localhost
Example:
At: /etc/hosts:
127.0.0.1 myservername.localhost
On the virtual-hosts of your server configuration you'll need to rename the server name. In my case, i'm using apache so at /etc/apache/sites-enabled/myserver.conf rename the line of the old server name with:
...
ServerName: myservername.localhost
If you are behind a proxy, you can except all the hosts just adding to the no_proxy vars:
$no_proxy= "localhost"
Finally don't forget to restart the server and try to access on the browser with the new server name.
Upvotes: 2
Reputation: 91
While it was stated that no proxy is being used, I have had the same issue on OS X while using a proxy and the eventual solution was to add a proxy-exception for this domain.
What the OP could try is turn off async DNS via command-line switch as mentioned here in 2015:
Async DNS: Remove toggle from about:flags
Async DNS is fairly stable at the moment, so we don't really need the toggle in about:flags anymore. (Note that the --enable-async-dns and --disable-async-dns command-line flags will still work for now.)
This, however, seems to have no effect in my case, as chrome://net-internals/#dns
still displays the internal DNS-client as enabled with no obvious way to turn it off.
Upvotes: 1
Reputation: 253
Try clearing the DNS Cache:
1) run cmd.exe as administrator
2) type: ipconfig /flushdns
Upvotes: 4