Localhost Redirecting to HTTPS for .dev Domains
Google’s motto has famously been “Don’t be evil”. But after an hour of troubleshooting why my .dev localhost domains were not working this morning, I have come to the conclusion that GOOGLE IS EVIL (maybe an exaggeration but I’m really not happy with them today). I’ll explain.
After updating my Mac, I was unable to load any of my localhost .dev domains in MAMP. They were redirecting to https://domain.dev. I tried restarting MAMP, rebooting my Mac, updating MAMP. Nothing was working. Then I realized it was only happening in Chrome and Safari, not Firefox. After some digging, I found the true culprit.
Google bought the TLD .dev. And new versions of Chrome and Safari FORCE your browser to load any website with .dev domain to https. When I updated MacOS and restarted my computer, Chrome and Safari must have installed their updates, breaking all of my localhost dev sites. THANKS GOOGLE.
So what’s the solution? You’ll need to change all of your local sites from .dev to .test (or another TLD recognized as a “special” TLD). You can read that list here. But currently the only safe TLDs are:
Any other name like the popular .local could be purchased in the future and should probably be avoided but will work for now.
So, if you woke up this morning and were unable to get Chrome or Safari to resolve your localhost .dev domain, you now know why. Change them to .test, restart MAMP (WAMP, XAMPP, .etc), and start using the new domain for testing local sites.
If any of your sites are WordPress, you can use this plugin to change every instance of the URL in the WordPress database: https://wordpress.org/plugins/velvet-blues-update-urls/.
You could also hardcode the site URL in the WordPress wp-config file: https://codex.wordpress.org/Changing_The_Site_URL.