Mac seems to be ignoring new changes to my hosts file. Older changes work without a problem. I've spent the past 4 hours trying to figure this one out. Help!
I have folders for each site that I develop in my /Sites folder. For example, several folders are named:
wp.dev
daf.dev
test.dev
I run MAMP, set the Apache Port to 80 and the MySQL Port to 3306 (so that I don't have to add the port to the address bar in a browser).
I have edited my /private/etc/hosts file as follows:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 wp.dev
127.0.0.1 daf.dev
127.0.0.1 test.dev
fe80::1%lo0 localhost
Here's the kicker: wp.dev and daf.dev have been around for over a month. They resolve without a problem in my browser. I added test.dev this morning. When I type it into a browser it simply searches "test.dev" as opposed to resolving a domain.
I can ping any of the above domains and they go to 127.0.0.1, including test.dev.
For what it's worth, I've tried virtualhostsx with the same problem. I also run dscacheutil --flushcache and restart MAMP when making changes.
I need to kick off development on a new site, and this is driving me crazy.
Exit with Ctrl + X. In Terminal, type sudo killall -HUP mDNSResponder followed by Return to clear your Mac's DNS cache and prevent any clashes between DNS and the Hosts file.
To prevent the computer from communicating to any external DNS name, add the relevant name to the HOSTS file and point it to the 127.0. 0.1 IP address (which is the local host itself), or to 0.0.
The Hosts file on a Mac is found in the /etc/hosts folder.
Safari on Big Sur can load some websites you've blocked in /etc/hosts , because it gets their IP addresses from these new HTTPS records.
Try putting all your entries at the top of the file.
Not really logical, but worth a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With