Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Mac » How to locate and edit the host file on macOS
  • task kill keyboard feature 1000x450 1
    Task Kill vs Stop Process: How to search for a service PID Windows Server
  • Create AWS RDS instance
    How to create an Amazon Relational Database Service Instance AWS/Azure/OpenShift
  • rdp5
    Change expired RDP Password: How to change a password on a Remote Desktop session Windows Server
  • MacOS Catalina Desktop
    Mac FileVault Encryption: How to enable FileVault disk encryption Security | Vulnerability Scans and Assessment
  • vmca course
    Veeam Certified Architect: VMCA Training & Certification Review Backup
  • Synology Cloud Sync
    How to Sync Data in Cloud Drives to Synology NAS Backup
  • feature photo terraform
    How to install Amazon RDS using Terraform Linux
  • microsoft confirms some pcs freeze after windows 10 2
    Information on BOOTP Vendor Extensions and DHCP Options Windows Server

How to locate and edit the host file on macOS

Posted on 06/04/202001/10/2024 Christian By Christian No Comments on How to locate and edit the host file on macOS
locate host file

In this article, we shall discuss how to locate and edit the host file on macOS. The hosts file on a Mac is a plain text file that maps hostnames to IP addresses. It’s a crucial part of the operating system’s networking configuration. This file allows you to override DNS settings for specific domains. Please see how to Run or Edit and Delete Tasks via Windows Task Scheduler, and How to Back Up and Restore the Windows Registry.

On macOS, accessing the hosts file is via the terminal. You can use your desired editor. I will be using the iTerm terminal as shown below.

Also, see How to locate and edit the host file on Windows, How to fix Computer Policy could not be updated successfully, and how to “‘Fix the request to add or remove features on the specified server failed“

Locate and edit the host file on macOS

Enter the command below “sudo vim /etc/hosts. Here I am using VIM which is a Text Editor in Unix Systems

edit host file

You will be prompted to enter your password as shown above and when the right credential is entered, the host database will be opened as seen below.

macOS host file
Be careful when editing the hosts file, as incorrect entries can disrupt your network access. Always make a backup before making changes. You can copy the original file to another location

To manipulate this file, use the “I” button on your keyboard in order to modify this field. This will let you enter a new host entry.

When you are done, you can hit the “Esc” button on your keyboard

  • Following by a semicolon “:”
  • For by “w” to save and
  • Followed by “q” to quit as shown below

Note: Editing the hosts file on a Mac is a powerful way to control domain resolution on your system. Whether you want to block websites, test local development, or override DNS settings, the hosts file offers a straightforward method for managing hostname resolution.

I hope you found this article very useful. Please feel free to leave a comment below.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Mac Tags:DNS, DNSRecord, Terminal

Post navigation

Previous Post: How to locate and edit the host file on Windows
Next Post: How to move a computer object from one container (OU) to another

Related Posts

  • PNG JPGconversion 2
    How to change the default screen capture format in macOS Mac
  • VirtualinstallationonMac
    How to install Oracle VirtualBox on a Mac device Mac
  • Screenshot 2020 06 22 at 11.33.46
    How to fix Bluetooth not available on MacBook Mac
  • screenshot 2020 05 11 at 20.03.56
    How to remove printers from HP Utility Mac
  • Enable or Disable Mac asking for Password
    Enable or Disable Mac asking for Password after Sleep or Screen Saver Mac
  • Norton iOS Calender
    Scan Apple Calendar: Prevent Norton from scanning your Apple Calendar on iOS Anti-Virus Solution

More Related Articles

PNG JPGconversion 2 How to change the default screen capture format in macOS Mac
VirtualinstallationonMac How to install Oracle VirtualBox on a Mac device Mac
Screenshot 2020 06 22 at 11.33.46 How to fix Bluetooth not available on MacBook Mac
screenshot 2020 05 11 at 20.03.56 How to remove printers from HP Utility Mac
Enable or Disable Mac asking for Password Enable or Disable Mac asking for Password after Sleep or Screen Saver Mac
Norton iOS Calender Scan Apple Calendar: Prevent Norton from scanning your Apple Calendar on iOS Anti-Virus Solution

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • task kill keyboard feature 1000x450 1
    Task Kill vs Stop Process: How to search for a service PID Windows Server
  • Create AWS RDS instance
    How to create an Amazon Relational Database Service Instance AWS/Azure/OpenShift
  • rdp5
    Change expired RDP Password: How to change a password on a Remote Desktop session Windows Server
  • MacOS Catalina Desktop
    Mac FileVault Encryption: How to enable FileVault disk encryption Security | Vulnerability Scans and Assessment
  • vmca course
    Veeam Certified Architect: VMCA Training & Certification Review Backup
  • Synology Cloud Sync
    How to Sync Data in Cloud Drives to Synology NAS Backup
  • feature photo terraform
    How to install Amazon RDS using Terraform Linux
  • microsoft confirms some pcs freeze after windows 10 2
    Information on BOOTP Vendor Extensions and DHCP Options Windows Server

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,841 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.