Change hosts file does not have any effect
I'd recommend  Gas Mask (freeware, no affiliation) which not only eliminates the need to try hack it in terminal, but also allows you multiple versions of the hosts file, switchable on the fly, instant response.



To use, Create a new file - it will setup the defaults automatically. Copy/paste any existing setup you want to carry over from any file to any other. Add any new data in the same format - it's very lenient on formatting, tab or space.
Save, then activate.
You can swap profiles any time the app is running, otherwise your last chosen will persist.
Activating a profile makes it immediately available.
 Note: the use of 127.0.0.1 rather than localhost for IPV6 is non-standard, but just seems to make the Mac behave better