How to Edit your Hosts File on a Mac Updated on September 19, 2023 by InMotion Hosting Contributor 2 Minutes, 8 Seconds to Read Your computer uses the HOSTS file to look up/resolve domain names to an IP address. This file can force your computer to resolve your website to a specific IP address rather than using the DNS entries indicated by the domain’s name servers. Manually configuring your domain with the IP address of your InMotion Hosting server will allow you to point a domain name to a different server location using an IP address. A HOSTS file change is intended to be temporary and should not be used with the published website. Video – How to Edit Your HOSTS File on a Mac Edit the HOSTS File in a Terminal Client How to Flush the DNS Cache Table of Contents Video – How to Edit Your HOSTS File on a Mac Edit HOSTS File in a Terminal Client How to Flush the DNS Cache Video – How to Edit Your HOSTS File on a Mac Edit HOSTS File in a Terminal Client You can use a terminal client application, or the one Apple provides in its operating system when editing your HOSTS file. Open the Terminal client of your choice. Edit the HOSTS file in the terminal window using one of the commands below.sudo nano /private/etc/hostsFor newer versions of Mac OS, use this command:sudo nano /etc/hosts Enter your Apple login password for your device. Edit the HOSTS file by adding these two lines.SERVER_IP_ADDRESS domain.comSERVER_IP_ADDRESS www.domain.comThis is an example of how it would appear in the HOSTS file:86.75.30.9 domain.com86.75.30.9 www.domain.com NOTE: Replace “domain.com” with your actual domain name. If you are unsure which IP address to use, please contact our Support Department for further assistance. Save your changes by pressing Control-O on your keyboard, then hit the enter key to accept the filename. Exit the editor by pressing Control-X. How to Flush the DNS Cache You may need to flush your Mac’s DNS cache for the HOSTS file change to work. Use the following command to flush the cache: Open your Terminal client. Type in the following command: dscacheutil -flushcache Hit enter to run the command. This completes the HOSTS file modification. You can now see your website using a domain name pointing to the specific IP address you added to the HOSTS file. If you no longer need the changes in the HOSTS file you can repeat the steps above and remove the changes you added. If you are using Windows, please refer to our guide on how to Modify Your Hosts File Using Windows. Learn more about DNS management with our DNS and Nameserver Changes Education Channel. Enjoy high-performance, lightning-fast servers with increased security and maximum up-time with our Secure VPS Hosting! Linux VPS cPanel or Control Web Panel Scalable Website Migration Assistance Linux VPS Hosting Share this Article InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles Setting SMTP settings in SMF 2.0 How to Install ownCloud Apps How to Install BoxBilling Manually How to Log Into ownCloud AbanteCart Maintenance Mode How to create a basic profile in Logaholic Installable Software Reference What is Docker? Working with Docker Containers Ubuntu Server: A General Overview