How to edit the Hosts file on Mac OS X

0

Sometime, you’d want to use the Hosts file instead of just letting DNS do its thing. For example, you are testing your sites before public it. Or you want to move site from old hosting to new hosting but dont want your site down. That’s why you can use the hosts file instead: Enter the server’s IP address or subdomain and when you use that domain name, your Mac will go to that device instead. In this tutorial, i want to access google.com but it will show content from yahoo server instead of Google server. Let’s try it.

How to edit the Hosts file

In this tutorial, i will use Terminal application found in your Mac’s Utilities folder to edit hosts file. The hosts file is locate at /etc/hosts on your MAC computer.
To open Terminal on your MAC, follow these step:
Step 1: Click on the Launchpad icon at the bottom bar on your MAC (red circle in below picture) and then click into Other:

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX step 1

Step 2: On Other screen, click into Terminal icon:

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX step 2

Step 3: Terminal Window will open, type: sudo nano /etc/hosts and then hit Enter (Return) on your keyboard. It will ask for permission, please enter your password and press Enter (return) to continue:

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX step 3

Step 4: Screen with /etc/hosts contents will show up. Move your mouse to the end of contents and enter your destination IP, and domain name you want to move as picture below (in green circle) – you can type the IP address, hit tab, then type the domain name. In this example, i will move google.com to 106.10.138.240, that’s a Yahoo server IP. Each move to one line. Press Enter (Return) to break line.

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX step 4

Step 5: After you’ve done, hold down the Control and O keys to save the file, then control and X to exit.

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX step 5

Step 6: It will back to Terminal screen. Type sudo killall -HUP mDNSResponder and then press Enter (Return). This command will flush your Mac’s DNS cache.

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX step 6

Step 7: Open Safari and then type your domain (in my case is Google.com) and then enter. You should see the contents of new IP server.

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on MAC OSX

How to edit the Hosts file on Mac OS X
5 - 1189 votes

Same tags:

  1. How to edit hosts file in Windows 10?

Other Posts you may be interested in:

  1. Fixed: Google sitemap error “Invalid tag value. This XML tag has an invalid value”
  2. Windows 10 Keyboard Shortcut
  3. Làm thế nào để boot vào Safe Mode trong windows 10?
  4. Hiển thị số lần xem bài viết trong WordPress không cần Plugin
  5. Bộ hình nền máy tính Bikini chất lượng Full HD 1920×1080
  6. Ất Mùi 2015 – việc nên làm và không nên làm
  7. 26 điều bạn nên “có kiêng” để “có lành”

Comments

Leave A Reply