Home > News Tips

[5 Best Fixes] How to Do with Hosts File not Working on Mac?

Updated on Tuesday, December 3, 2024

iBoysoft author Sherry Song

Written by

Sherry Song
Professional tech editor

Approved by

Jessica Shee

English Français Deutsch やまと Español Português

Mac Hosts file is a plain text file, mapping hostnames to IP addresses, which is used to convert a request by name to a numeric IP address. So Hosts files on our Mac play a crucial role in managing domain name resolution.

However, users may encounter problems with Mac host file issues such as the Host file not working on Mac as expected. This article explores effective solutions and the reasons behind addressing such concerns and ensuring optimal performance.

Summary of Hosts File not Working on Mac

How to fix Mac Hosts file not working?

When faced with issues related to the Hosts file not working on Mac, consider the following steps to troubleshoot and resolve the problem.

Fix1: Check file permission

Ensure that the file permissions for the Mac Hosts file are configured correctly. You can use the Apple built-in tool Terminal to check:

  1. Finder > Applications > Utilities > Terminal.
  2. Type ls -l /etc/hosts and press Enter, then the window will display detailed information about the Hosts file and its permissions. 
     Check file permission
  3. Understand the Output results.
    rw- means the owner(root) has read and write permissions. 
    r-- means the group(wheel) has read-only permissions. 
    r--means others have read-only permissions. 
    (r stands for read, w stands for write, x stands for execute)
  4. If your permissions are different, modify it to type sudo chmod 644 /etc/hosts. (It will reset read and write permissions.)

Fix 2: Verify host file content

You can review the contents of the host files using TextEdit and confirm that the entries are in the correct format then check whether the macOS Hosts file not working is fixed or not.

  1. Finder > Applications > Utilities > Terminal.
  2. Type cat /etc/hosts and press Enter, then the window will display the contents of the Hosts files.
  3. Check the IP addresses and domain names are correctly paired. ( It should be IP_Address Domain_name.)
     Verify Mac Host file content
  4. If you need to make edits to the file, type sudo open -e /etc/hosts. It will open TextEdit and you can make edits and save the file.

Fix 3: Restart networking services

This fix will flush the DNS cache and restart the mDNSResponder, which handles the networking service on macOS.

  1. Finder > Applications > Utilities > Terminal.
  2. Type sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder and press Enter
  3. Enter your password and press Enter.

Fix 4: Disable IPv6 in network preferences

Some users have reported the issues that the hosts file not working on Mac when IPv6 is enabled. You can try disabling IPv6 in your network preferences to see if it resolves the problem.

  1. Apple menu > System Settings > Network.
  2. Select the network connection for which you want to disable IPv6.
  3. Choose the Details > TCP/IP > Configure IPv6 > Click the arrow and choose Link-Local Only then tap OK
    Disable IPv6 in network preferences 
  4. Repeat the Fix 3.

Fix 5: Check for system integrity protection(SIP)

On recent macOS versions, System Integrity Protection(SIP) protects certain system files including the hosts file. Ensure that SIP is not preventing changes to the hosts file. You can check SIP status by fixing the Mac Hosts file change not working:

  1. Finder > Applications > Utilities > Terminal.
  2. Type csrutil status and press Enter. The current status of SIP will be displayed. 
     Check for SIP
  3. Check SIP status is enabled. 
    If SIP is enabled, it will show System Integrity Protection status: enabled. 
    If SIP is disabled, it will show System Integrity Protection status: disabled.

After trying these fixes, restart your Mac and check Mac Hosts file not working is fixed. Share these ways to help more people.

The reasons for Mac Hosts file not working

There are several potential reasons why the Hosts file not working on Mac. Understanding these reasons can help in troubleshooting and resolving issues. Here are some common factors:

  • Incorrect file permissions
  • Syntax errors in Mac Hosts file
  • DNS cache issues
  • Networking services not restarted
  • IPv6 interference
  • System Integrity protection prevention
  • Hosts file corruption
  • Inaccuracies in file content
  • Third-party software interference
  • Misconfigured network settings
  • Insufficient privileges

By following these comprehensive steps and gaining insights into the issue that the Hosts file is not working on Mac, users can effectively address Hosts file-related problems on their Macs. Ensuring the proper functioning of Mac Hosts files is essential for seamless domain name resolution and overall system performance.