Reputation: 181
How can I set chrome to ignore hosts file?
Here is the scenarion: I have www.example.com site which is Live and customers are using it and now I have got the code hosted on a new server with a host file entry to that server for my domain I am able to browse to the new server. Problem is everytime I want to check whats on live I have to edit my host file entry. So is there an option to manually set one of my browsers ex: Chrome to ignore the host file entry?
Upvotes: 1
Views: 8123
Reputation: 1805
Well, not a solution to the actual problem (force the browser to ignore hosts file), but rather a flexible alternative.
Ok, so what you usually do in your site's configuration is to have a server alias for www.example.com
and example.com
. So, then you probably enter in your host file something like this 123.231.123.231 example.com
where that IP is your new server's IP and you access your site via example.com
. Right ?
Well, here's the catch, if you type www.example.com
in your browser instead of example.com
you will still see the old site, even if you have set alias with www in your new server's configuration. I think you can apply the same trick with http and https, but you get the idea.
Hope this helps.
Upvotes: 0
Reputation: 181
There is no straight forward solution. The sort of temporary solution is Browser loads host file only when its loaded so I ended up editing the hostfile entry open the browser instance and changed the host file entry back. So that way the new browser opened will have a new host file entry loaded.
Upvotes: 0
Reputation: 320
As it turns out you may be able to use an issue with Chrome to accomplish this. I was having trouble getting Chrome to recognize/use my /etc/hosts file to locate locally defined IPs. It was always doing a search on the name rahter than going to the locally defined domain.
I had to comment out these 2 lines to get it to work:
So, I am guessing that if you put them in, Chrome will ignore your hosts file. It seems it is an issue the Chrome has with IPv6, so as long as you only need IPv4 for the things in your hosts file you may be able to use this Chrome bug to accomplish what you want. At least until it gets fixed...
Upvotes: 0
Reputation: 6510
No, I don't think you can, since the hosts file is an operating system wide setting. It would be easier and better to manage if you change the domain of the test server to www.example.local, so www.example.com will go to the live server.
Edit: Another simple solution would be to use a browser in a virtual machine. It could be worth the effort if you need to do a full testing
Upvotes: 0