---
title: "How to Edit your Hosts File on a Mac"
description: "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..."
url: https://www.inmotionhosting.com/support/edu/software/how-to-edit-your-hosts-file-on-a-mac/
date: 2011-08-26
modified: 2023-09-19
author: "InMotion Hosting Contributor"
categories: ["Software"]
type: post
lang: en
---

# How to Edit your Hosts File on a Mac

![](https://www.inmotionhosting.com/support/wp-content/uploads/2023/03/hosts-change-mac-1024x538.jpg)

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](#video)
- [Edit the HOSTS File in a Terminal Client](#edit-hosts)
- [How to Flush the DNS Cache](#flush)

## Video – How to Edit Your HOSTS File on a Mac

![How to Edit Your Hosts File on a Mac](https://i.ytimg.com/vi_webp/1x4B_pU2HZ8/maxresdefault.webp)

## Edit HOSTS File in a Terminal Client

You can use a terminal client application, or the one [Apple provides](https://support.apple.com/guide/terminal/welcome/mac) in its operating system when editing your HOSTS file.

1. Open the [**Terminal**](https://www.inmotionhosting.com/support/server/ssh/shared-server-ssh-mac/) client of your choice.
2. 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
3. Enter your Apple login password for your device.
4. Edit the HOSTS file by adding these two lines.**SERVER_IP_ADDRESS** domain.com**SERVER_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](https://www.inmotionhosting.com/support/amp/how-to-get-great-technical-support/) for further assistance.
5. Save your changes by pressing **Control-O** on your keyboard, then hit the **enter** key to accept the filename.
6. 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:

1. Open your Terminal client.
2. Type in the following command: `dscacheutil -flushcache`
3. 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](https://www.inmotionhosting.com/support/website/modifying-your-hosts-file/).

Learn more about DNS management with our [DNS and Nameserver Changes](https://www.inmotionhosting.com/support/domain-names/dns-nameserver-changes/) Education Channel.

![Secure VPS Hosting](https://design.inmotionhosting.com/assets/icons/custom/security.svg)Enjoy high-performance, lightning-fast servers with increased security and maximum up-time with our [Secure VPS Hosting](https://www.inmotionhosting.com/vps-hosting)!

![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Linux VPS ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)cPanel or Control Web Panel ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Scalable ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Website Migration Assistance

[Linux VPS Hosting](https://www.inmotionhosting.com/vps-hosting/linux-vps)
